Things you need to know as a Javascript Developer.

1. Variable :

In Javascript, variable can be declared with 3 keywords : var, let, const. There are also some naming convention of variables.

1. Camel Case : firstName, lastName, userName

2. Pascal Case : FirstName, LastName, UserName

3. Snake Case : first_name, last_name, user_name

4. Kebab Case : first-name, last-name, user-name

2. Difference between “==” and “===” :

“==” : This only checks if the values of two variables are equal or not.

“===” : This checks if the values and datatypes of two variables are equal or not.

3. Difference between the declaration of an Array nd an Object :

Arrays are declared with the Third Bracket : []

const names = [‘John’, ‘Sadad’, ‘Niloy’, 15, 31, 45 ]

Objects are declared with the Second Bracket : {}

const person = {name: “John Kabir”, id:0231}

4. Difference between Undefined and Null :

Undefined : It means a variable is declared , but no value has been assigned in that variable.

Example : let a;

Null : It means a variable is declared and you can assign null in that variable.

Example : let a = null;

5. 2 Ways of accessing Object Properties :

let person={name: ‘Niloy Rahman’, id: 02}

1.person.name;

2.person[“name”];

6. Ternary Operator :

It is used instead of if else now a days. You can call it as a single line if else.

Look at the problem below :

let marks = 75;

let grade;

if(marks>40){grade = ‘Passed’}

else{grade= ‘Failed’}

we can write these code with ternary operator :

let grade = marks>40 ? ‘Passed’ : ‘Failed’

7. Important Array Methods :

find() : This find()method makes the return of the first found element towards the array, that is tested with the provided functions. In case the element is discovered it then returns undefined. Check the following:

const someArray = [
{ id: 1, name: "John" },
{ id: 2, name: "Smith" },
{ id: 3, name: "Bob" },
]
someArray.find(element => element.id === 2)

//-------> Output : {id: 2, name: "Smith"}

forEach(): In case of the forEach()method the user uses the function on every element of the array.

const someArray = [
{ id: 1, name: "John" },
{ id: 2, name: "Smith" },
{ id: 3, name: "Bob" },
]
myAwesomeArray.forEach(element => console.log(element.name))

//Output : John, Smith, Bob

map(): The new map()method that applies the functions as the parameters and create a new array that is populated with results of functions on each element.

const someArray = [1, 2, 3, 4]

someArray.map(x => x * x)
// Output: 1, 4, 9, 16

push() : Add new elements to the array and return their new length

a = fruit.push (“lemon”);

8. Destructuring :

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

Code :

let a, b, rest;
[a, b] = [10, 20];

console.log(a);
// expected output: 10

console.log(b);
// expected output: 20

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

How to check an element is in viewport

Xiaomi Redmibook: How to resolve wifi problem on linux (debian distros)

A simple wrapper to the mam.client for NodeJs

Interview Questions E1: Lets Pass Data from Child to Parent

Best svg resources for React Projects

How to get started with D3 and React

Move fast — let the type system prevent you from breaking things!

the display property

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adnankabir

Adnankabir

More from Medium

What does HOME mean to you?

For your good health, how many steps a day do you need?

CS373 Spring 2022: Mar 21-Mar 27

I’ll Always Have Paris — Chapter 7