Posts

STACK IN JAVASCRIPT

Image
  STACK IN JAVASCRIPT Implement Stack using array what is stack ? Stack is a linear data structure it follows LIFO(Last In First Out) or FILO(First In Last Out) principle.⬇️ PUSH( ) METHOD push method is used to push an element into end of the Stack . If you add an element they pushed/added in top of the stack.⬇️ POP( ) METHOD The element is popped from the top of the stack and they displayed from your screen.⬇️ UNSHIFT( ) METHOD unshift() method is  used to add one or more elements to the beginning of the given array …….⬇️ SHIFT( ) METHOD The shift() method  removes the first element from an array and returns that removed element ……⬇️ isEmpty() Return true if the stack is empty………⬇️ peek(); peek method shows top most element in stack………⬇️ size() It returns the length of the current stack…….…⬇️ clear() It r emoves all the items from the Stack…….. …⬇️ RECAP EXERCISE TIME:- Do it yourself…if you get the output comment below class Stack { constru...

JavaScript Functions Explained: A Beginner’s Guide with Examples

Image
  Functions in javascript Javascript Functions * A JavaScript function is a block of code. * A JavaScript function is executed when “something” invokes it. SYNTAX ….⬇️ A function is defined with the function keyword, followed by a  name , followed by  parentheses   () . The code to be executed, by the function, is placed inside curly brackets:  {} TRY THIS: function function_name() { console.log("hello world!"); } function_name(); TRY THIS: function greeting() { return `Hello ${user} !`; } let user = “bk_bharathikannan”; let string =greeting(); console.log(string); OR function greeting() { return "Hello " + user+"!!"; } let user = "bk_bharathikannan" let string =greeting(); console.log(string); Function parameters & Function arguments… ⬇️ Function parameters are the names of variables present in the function definition.   Function arguments are the real values that are passed to the function and received by them . TRY...

MICROSOFT POWERPOINT

Image
 

Understanding Event Loop, Call Stack, Event & Job Queue in Javascript

Image
  Understanding Event Loop, Call Stack, Event & Job Queue in Javascript In this article we will dig into how javascript works under the hood, how it executes our asynchronous javascript code, and in what order (Promise vs setTimeout), how it generates stack trace and much more.. As most developers know, that Javascript is single threaded, means, two statement in javascript can not be executed in parallel. Execution happens line by line, which means each javascript statements are synchronous and blocking. But there is a way to run your code asynchronously, if you use  setTimeout()  function, a Web API given by browser, which makes sure that your code executes after specified time (in millisecond). Example code: console.log('Message 1'); // Print message after 100 millisecond setTimeout(function() { console.log('Message 2'); }, 100); console.log('Message 3'); setTimeout  takes a callback function as first parameter, and time in millisecond as second paramet...

IMPLEMENTATION OF SINGLE LINKED LIST IN JS

Image
  IMPLEMENTATION OF SINGLE LINKED LIST IN JS (PART-1) What is linked list ?πŸ₯· A linked list is  an ordered collection of data elements . A data element can be represented as a node in a linked list. Each node consists of two parts: data field & link field. There are four types of linked list:- Singly linked list. ⬇️ Doubly linked list. ⬇️ Circular linked list. ⬇️ Doubly circular linked list. ⬇️ IMPLEMENTATION OF SINGLE LINKED LIST:- CLASS AND CONSTRUCTOR:- The constructor() method is called automatically when a class is initiated, and it has to have the exact name “constructor” , in fact, if you do not have a constructor method, JavaScript will add an invisible and empty constructor method.  Note : A class cannot have more than one constructor() method…… ‘’ IF YOU LIKE THIS ARTICLE GIVE A CLAP AND FOLLOW FOR MORE ARTICLES……IT GIVES HUGE MOTIVATION‘’πŸ’« 𝔻𝕠 π•ͺ𝕠𝕦 π•¨π•’π•Ÿπ•₯ 𝕑𝕒𝕣π•₯-𝟚 π•”π• π•žπ•žπ•–π•Ÿπ•₯ 𝕓𝕖𝕝𝕠𝕨⬇️ THINK TWICE πŸ’­ -code once! THANKS_FOR_READING_!🌟 ❤️ “Hav...

stack in javascript

Image
  STACK IN JAVASCRIPT Implement Stack using array what is stack ? Stack is a linear data structure it follows LIFO(Last In First Out) or FILO(First In Last Out) principle.⬇️ PUSH( ) METHOD push method is used to push an element into end of the Stack . If you add an element they pushed/added in top of the stack.⬇️ POP( ) METHOD The element is popped from the top of the stack and they displayed from your screen.⬇️ UNSHIFT( ) METHOD unshift() method is  used to add one or more elements to the beginning of the given array …….⬇️ SHIFT( ) METHOD The shift() method  removes the first element from an array and returns that removed element ……⬇️ isEmpty() Return true if the stack is empty………⬇️ peek(); peek method shows top most element in stack………⬇️ size() It returns the length of the current stack…….…⬇️ clear() It r emoves all the items from the Stack…….. …⬇️ RECAP EXERCISE TIME:- Do it yourself…if you get the output comment below class Stack { constructor() { this.ite...