Need You Know More JavaScript Fundamental Concept

Need You Know More JavaScript Fundamental Concept

Nayem Khan

--

Object and Function:
Description: In computer programming language fundamental things, a function object is a construct allowing an object to be or called as if it were an ordinary function, usually with the same syntax. Function objects are often called functors. An object is a collection of properties, and a property is an association between a name (or key) and a value. Obeject property’s value can be a function, in which case the property is known as a call function method.
Example:
const example = {name: ‘xxx’,age: ‘000’};
// console.log(example) output example ={“name”: “xxx”, “age”: “000”}

Primitive Value:
Description: All primitives are immutable, they cannot be altered. It is important not to confuse a primitive itself with a variable assigned a primitive value. The variable may be reassigned a new value, but the existing value can not be changed in the ways that objects, arrays, and functions can be altered. All types except objects define immutable values (that is, values which can’t be changed).JavaScript provides six primitive types as undefined, null, boolean, number, string and symbol.The size of a primitive value is fixed, therefore, JavaScript stores the primitive value on the stack.
Example:
let abc= 10; console.log(typeof(abc)); // output — number
let xyz= ‘JS’; console.log(typeof(xyz)); // output — string

Try…catch:
Description: JavaScript try and catch The try statement allows you to define a block of code to be tested for errors while it is being executed. The catch statement allows you to define a block of code to be executed, if an error occurs in the try block. try … catch {} method is used to be data load from the server like https:// same altranative work fetch method in javaScript language. there is three step method try, catch and finally. First try method call data type from server and second catch method call if first method return error then call catch method then return error message.
Example:
try {try statements}
catch{ catch statement}
finnally{finnally satements}

condition value of JavaScript:
Description: In general, the condition return to a Boolean value, like true or false . In case the condition return to a non-Boolean value, JavaScript implicitly converts its result into a Boolean value by calling the Boolean() method function. If the condition evaluates to true , the statement is executed and return boolean value. Condition statement like: if … else if … else if … else
Example:
if(condition){return value}
else if (condition){return value}
else{ false return value}

comments of JavaScript code:
Description: This is JavaScript comments can be used to be explaintion JavaScript code, and to make it more readable. And testing alternative code JavaScript in DOM . Comment type some formart given. Single line comments start with // . Multi Line comments start /* multiple line*/
Example:
// single line comments method
/* multiple line comments method*/

Block-Level-Declaration:
Description: Block-level declarations are those that declare variables that are inaccessible outside of a given block scope. Block scopes are created: 1) Inside of a function. 2) Inside of a block (indicated by the {and } characters). Block scoping is how many languages work, and the introduction of block-level declarations in ECMAScript 6 is intended to bring that same flexibility (and uniformity) to JavaScript. The block statement is often called compound statement in other languages. Prior to ES2015, block-level functions were forbidden in strict mode.

Block-Binding:
Description: Perhaps one area where developers most want block level scoping of variables is within for loops, where the throwaway counter variable is meant to be used only inside the loop. For instance, it's not uncommon to see code like this in JavaScript. In JavaScript, however, the variable i is still accessible after the loop is completed because the var declaration gets hoisted.
Example:
for (let i = 0; i<10; i++){proccess(items[i])}
console.log(i) //output — 1,2,3,4,5,6,7,8,9

Function with Default Value:
Description: A default argument is a value give in a function declaration that is automatically assigned by the return value if the caller of the function doesn’t give a value for the argument with a default value. Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed return proccess method.
Example:
function add(a, b = 2) {
return a * b;
}
const result = add(1)
console.log(result) // output is — 2

Spread Syntax:
Description:Spread syntax can be used when all elements from an object or array need to be included in a list of some kind..(…) is used as an argument for a variadic function. A variadic function is a function which can have a variable number of parameters. Spread syntax (…) allows an iterable such as an array expression or string to be expanded in this method. Spread syntax is used basically a array or object value get on this function method just call array or object name and before object or array name type … (three dots). Then Get all element and value given from object and array.
Example:
const obj ={name: “abc”, age: 25, loaction: “xxx”}
console.log({..obj}) // output is — full object value.

Arrow Function:
Description: Arrow functions were introduced in ES6. An arrow function expression is a compact alternative to a traditional function but is limited and can’t be used in all situations. Make Arrow functiona The examples above took perameter from the left of => and evaluated the right-side expression with them. Arrow function is used to be easy way in function declaration in JavaScript Languages.
Example:
const arrowFun = () => { function intems }
This is arrow function formart

--

--