DEV Community

loading...

Some Essential things in JavaScript

rianislam profile image Rian Islam ・2 min read

1.What are Cookies?
A cookie is a piece of data that is stored on your computer to be accessed by your browser. You also might have enjoyed the benefits of cookies knowingly or unknowingly. Have you ever saved your Facebook password so that you do not have to type it each and every time you try to log in? If yes, then you are using cookies. Cookies are saved as key/value pairs.

2.Javascript Set Cookie

You can create cookies using document. cookie property like this.

document.cookie = "cookiename=cookievalue"

3.What is DOM in JavaScript?
JavaScript can access all the elements in a webpage making use of Document Object Model (DOM). In fact, the web browser creates a DOM of the webpage when the page is loaded.

4.JavaScript Hoisting
Hoisting is the default behavior of moving all the declarations at the top of the scope before code execution. Basically, it gives us an advantage that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local.
It allows us to call functions before even writing them in our code.

5.Variable Scope

In JavaScript, the scope of a variable is controlled by the location of the variable declaration, and it defines the part of the program where a particular variable is accessible.
there are three ways to declare a variable in JavaScript: by using the old var keyword, and by using the new let and const keywords.

6.JavaScript Arrow Function
Arrow function is one of the features introduced in the ES6 version of JavaScript. It allows you to create functions in a cleaner way compared to regular functions.
For example:
// using arrow functions
const x = (x, y) => x * y;

7.JavaScript Comment
The JavaScript comments are meaningful way to deliver message. It is used to add information about the code, warnings or suggestions so that end user can easily interpret the code.

8.splice() method in JavaScript
The JavaScript splice() method changes the elements of the array by replacing or removing the elements, in place.

9.What are JavaScript Data Types?

Following are the JavaScript Data types:

Number
String
Boolean
Object
Undefined
Enter fullscreen mode Exit fullscreen mode
  1. What is === operator?

=== is called a strict equality operator, which returns true when the two operands have the same value without conversion.

Discussion (0)

Forem Open with the Forem app