DEV Community

Cover image for Free Fire JavaScript Concepts
Emon Ahmed
Emon Ahmed

Posted on • Updated on

Free Fire JavaScript Concepts

Hello Everyone, Today We Will Discuss About SOME JS Concepts. We Have a Perfect Name For This BLOG, Which is called, Free Fire JS Concepts. Sound Cools. Because There Are Lot Of GAMERS, I Know BUT, Today Topic is not Gaming, Something Crazy. Because We Will Clear Some Concepts Here. Let's Start,

Image description


How JavaScript Work

JavaScript is A client side Programming Language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled and multi-paradigm. JavaScript is single-threaded. Because while running code on a single thread, it can be really easy to implement as we don't have to deal with the complicated code scenario. JavaScript is always synchronous.

consol.log("I Love JavaScript")
Enter fullscreen mode Exit fullscreen mode

When the browser loads the page, the browser has a built-in interpreter that reads the JavaScript code it finds in the page and runs it. Chrome Has Chrome V8 For Running JavaScript in Chrome Browser. And FireFox Has SpiderMonkey.


JavaScript String

String is a primitive data type in JavaScript. The JavaScript string is an object that represents a sequence of characters.
We can define string like this:

let txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Enter fullscreen mode Exit fullscreen mode

There are 3 methods for extracting a part of a string:

slice(start, end)

let str = "Apple, Banana, Kiwi"; 
let part = str.slice(7, 13);
Enter fullscreen mode Exit fullscreen mode

substring(start, end)

let str = "Apple, Banana, Kiwi"; 
let part = str.substring(7, 13);
Enter fullscreen mode Exit fullscreen mode

substr(start, length)

let str = "Apple, Banana, Kiwi"; 
let part = str.substr(7);
Enter fullscreen mode Exit fullscreen mode

Event bubbling in JavaScript

Event bubbling is a method of event propagation in the HTML DOM API. When an event is in an element inside another element, and both elements have registered a handle to that event. The bubbles event property returns a Boolean value that indicates whether or not an event is a bubbling event.

Image description


Handle Exceptions - Try-Catch

We use Try-Catch-Finally For Handle Exceptions. Our Main Code in Try, And If We Face Any Error Then Catch Will Work, If We Set Any Error Message, That will be in Catch Area, And If We want TO Run Any CODE Without Any Try Catch, We Will Use Finally Method.

try {
  // Try to run this code 
}
catch(err) {
  // if any error, Code throws the error
}
finally {
  // Always run this code regardless of error or not
  //this block is optional
}
Enter fullscreen mode Exit fullscreen mode

Closure in JavaScript

Closure Function is a function which has access to the variable from another function's scope. Whenever a function is declared in JavaScript closure is created. Returning a function from inside another function is the classic example of closure.

Image description

Top comments (0)