Skip to main content

Command Palette

Search for a command to run...

JavaScript Syntax

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

Updated
β€’3 min read
JavaScript Syntax
A
Software engineer and developer educator with over four years of experience building production-grade digital products for platforms serving millions of developers globally. Software engineer at Hashnode & Bug0

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 πŸ™.

I

This is pretty interesting Ayodele Samuel Adebayo well detailed πŸ™Œ

2
A

Thanks a lot sir, I appreciate the feedback.

Glad you liked it 😊

2

More from this blog

U

Unclebigbay's πŸš€ Blog

101 posts

Software Engineer | Open-Source Contributor | Developer Educator