All About JavaScript

Umme Salma Ali
3 min readMay 6, 2021

So… today we’ll dive into JavaScript for another time.

Error Handling: First of all, we’ll discuss about JavaScript error handling. What is Error handling in JavaScript? Well in JavaScript error handling consists of two particular terms. These are 1.try and 2. catch. If you’re a great programmer yet you’ll get errors in your code instead of being an expert programmer. There’s no particular reason behind an error. It may even cause because of network issues or server related issues. To get rid of this we use try and catch method in JavaScript. i.e.

try{

//(code)

}catch(err){

//(error handling)
}

Coding Style: The coding style varies programmer to programmer. This is basically the art of coding by the programmer. Yet we’ve to follow some built-in parenthesis to make our code readable. These are also called syntax of coding. The parenthesis include curly braces, line-length, code-indentation, vertical indents, semi-colon, nesting levels, function placement. All of these make our cod readable

Comments: We use comments to indicate what is the code about for our future readability so that we can understand what is functionality of that particular code. There are two types of comments 1.Bad Comments which too much explanation about the coding,. Again there is Good Comments which allows us to maintain the code well, returning to it so that we can use it more effectively.

Let’s talk about something different:

Default Parameters: When a function is called is missing arguments with default parameters, then the parameters are set as undefined but it is better to assign a default value to the parameter.

The argument object: The JavaScript functions have a built in object called argument object. In an argument object, there’s an array of arguments used when the functions are invoked.

The Spread Operators: The spread operators is completely a new edition to the JavaScript in Es6. It takes in an array and expands it into individual elements. Usually the spread operators are denoted by three dots. i.e.

let demo_array = [“1”,”2’’,”3’’]

…demo_array = “1”,”2’’,”3’’

Coping an Array: The second array has the element of first array copied into it. Any changes made to the first array will not be reflected in the second array. i.e.

let first-array = [‘4’, ‘5’, ‘6’]

let second_array = […first_array]

//[‘4’, ‘5’, ‘6’]

Inserting the Elements of one array into another: We can see that spread operator are used when when we need to append one array after any element of another array.

let fruits = [‘apple’, ‘malta’, ‘orange’]

let summer_fruits =[‘banana’, ‘mango’, ‘lichi’]

let all_fruits = [‘watermelon, ‘papaya’,…fruits, ‘guava’,…summer_fruits]

Block Level Functions: The Block level functions declarations are allowed in ES6. They are hoist to the top of the block. When it is in strict mode, they are not visible outside the containing block.

Arrow Functions: Arrow Functions is an extension to the traditional function expression but it’s functionality is limited to some extent which are:

Arrow function does not have it’s own bindings to this or super and it can not be used as methods. It doesn’t have arguments and new.target keywords. This is not suitable for call, bind and apply methods. Furthermore, it can’t be used as constructors.

--

--

Umme Salma Ali
0 Followers

A curious programmer who always want to explore more about new technology and wanna stay updated with technology.