JavaScript Syntax

JavaScript Syntax profile { }, [ ], ( ) and more ...

JavaScript Syntax

Hello, my gorgeous friends on the internet ๐Ÿ‘‹

Below are lists of JavaScript syntax with their information broken down into profile details and examples.

I hope you find this helpful, let's get started.

giphy (7).gif

1. [ ]

English Name: Square Brackets

JavaScript Use: To declare an Array

Example ๐Ÿ‘‡:

const favouriteFruits = [ "Mango", "Pawpaw", "Cashew" ];

2. { }

English Name: Curly brackets or braces

JavaScript Use: To create an Object Literal

Example ๐Ÿ‘‡:

const favouriteBloggers = {
name: "Mr. Tapas", 
site: "blog.greenroots.info"
}

3. ( )

English Name: Parentheses

JavaScript Use: To invoke functions or methods.

Example ๐Ÿ‘‡:

const newFunction = ()=>{

// log() method
    console.log("๐Ÿ˜Ž");
}

// Invoke function()
newFunction()

4. ...

English Name: 3 dots, full stops or periods

JavaScript Name: Spread Operator

JavaScript Use: To merge 2 or more arrays together

Example ๐Ÿ‘‡:

const halfName = ["uncle"];

const otherhalfName = ["Bigbay"];

console.log(...arrayOfHalfName, ...otherHalfName)

Output ๐Ÿ”Ž

image.png


5. ??

English Name: Question Marks

JavaScript Name: The nullish coalescing operator

JavaScript Use: To return the right-hand operand when the left-hand operand is null or undefined

Example ๐Ÿ‘‡:

const formField = null; // replace with a value

const formResponse = formField ?? "This Field is required";

console.log(formResponse);

6. &&

English Name: And

JavaScript Name: Logical AND

JavaScript Use: To return the right-hand operand when the left-hand operand is not "false"

Example ๐Ÿ‘‡:

const isUserLoggedIn = true; // Change to false or string

const authenticationStatus = isUserLoggedIn && "Yes, ๐Ÿ˜€";

console.log(authenticationStatus);

7. ||

English Name: Vertical Bar

JavaScript Name: Logical OR

TypeScript Name: Double Pipe Operator

JavaScript Use: Returns true if any of the conditions in an expression is true.

Example ๐Ÿ‘‡:

// Recruitment application ๐Ÿ˜Ž

const webDeveloper = true;

const hasExperience = false;

// Qualified if any of the condition is true

const qualified = webDeveloper || hasExperience;

if (qualified) {

  console.log("You're welcome onboard ๐Ÿค—");

} else {

  console.log("You are not one of us ๐Ÿ˜ญ");

}

Output ๐Ÿ”Ž

image.png


8. ? :

English Name: Unknown ๐Ÿ˜œ

JavaScript Name: Ternary Operator

JavaScript Use: Alternative to if else block

Example ๐Ÿ‘‡:


const finalExamDay = 19;

// If final exam day is zero, I am happy else I really don't enjoy school

const mood = finalExamDay === 0 ? "Happy, coding time ๐Ÿ’ƒ" : "I hate school ๐Ÿ˜ฅ";

console.log(mood);

Output ๐Ÿ”Ž

image.png


9. ++ Operand

English Name: Plus Sign

JavaScript Name: Increment

JavaScript Use: To increase its operand by one (1) and return a new value

Example ๐Ÿ‘‡

let point = 0;

const makePoint = ++point;

console.log(makePoint);

Output ๐Ÿ”Ž

image.png


10. -- Operand

English Name: Minus Sign

JavaScript Name: Decrement

JavaScript Use: To deduct one (1) from its operand and return a new value

Example ๐Ÿ‘‡

let point = 1;

const losePoint = --point;

console.log(losePoint);

Output ๐Ÿ”Ž

image.png


Wow, what a journey, I am glad you made it to the end of this article, if you enjoyed and learned something new from this article, you can subscribe to my newsletter to get notified of my upcoming articles.

I will also like to connect with you, let's connect on:



See you in the next article. Bye Bye ๐Ÿ™‹โ€โ™‚๏ธ

image.png

If you found my content helpful and would want to support my blog, you can support me by buying me a coffee below, my blog lives on coffee ๐Ÿ™.