Ayodele Samuel Adebayo
Unclebigbay's 🚀 Blog

Unclebigbay's 🚀 Blog

JavaScript Syntax

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

Ayodele Samuel Adebayo
·Aug 17, 2021·

3 min read

JavaScript Syntax

Subscribe to my newsletter and never miss my upcoming articles

Play this article

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 🙏.

 
Share this

Impressum

Hi 🙋‍♂️, I am glad you made it to my blog, I would like to connect with you, I am active on