The "Top 54 JavaScript Interview Questions" PDF covers a comprehensive set of JavaScript topics, including data types, object creation, functions, cookies, variable scopes, the 'this' keyword, closures, arrow functions, debugging, and more. It provides detailed insights into JavaScript concepts through questions and answers. You can access the full document for an in-depth understanding of these essential JavaScript interview topics.
1. What do you understand about JavaScript?
2. What’s the difference between JavaScript and Java?
3. What are the different types of data available in JavaScript?
4. What are the features of JavaScript?
5. What benefits does JavaScript offer compared to other web technologies?
6. How can an object be created in JavaScript?
7. How can an array be created in JavaScript?
8. What are some of the pre-existing methods available in JavaScript?
9. What are the scopes of a variable in JavaScript?
10. What is the ‘this’ keyword in JavaScript?
11. What are the conventions of naming a variable in JavaScript?
12. What is Callback in JavaScript?
13. How do you debug a JavaScript code?
14. What distinguishes a Function declaration and Function expression?
15. How can you include JavaScript code in an HTML file?
16. What do you understand about cookies?
17. How would you create a cookie?
18. How would you read a cookie?
19. How would you delete a cookie?
20. What’s the difference between let and var?
21. What are Closures in JavaScript?
22. What are the arrow functions in JavaScript?
23. What are the various methods to access an HTML element in JavaScript code?
24. What are the methods for defining a variable in JavaScript?
25. What are Imports and Exports in JavaScript?
26. What is the differences between Document and Window in JavaScript?
27. What are some of the JavaScript frameworks and their purposes?
28. What is the difference between Undefined and Undeclared in JavaScript?
29. What is the differences between Undefined and Null in JavaScript?
30. What is the difference between Session storage and Local storage?
31. What are the different data types that exist in JavaScript?
32. What is the ‘this’ keyword in JavaScript?
33. What is the difference between Call and Apply? (explain in detail with examples)
34. What are the scopes of a variable in JavaScript?
35. What are the arrow functions in JavaScript?
36. Explain Hoisting in JavaScript. (with examples)
37. Difference between “==” and “===” operators (with examples)
38. Difference between var and let keyword
39. Implicit Type Coercion in JavaScript (in detail with examples)
40. Is JavaScript a statically typed or a dynamically typed language?
41. NaN property in JavaScript
42. Passed by value and passed by reference
43. Immediately Invoked Function in JavaScript
44. Characteristics of JavaScript strict mode
45. Higher Order Functions (with examples)
#JavaScriptInterviewQuestions #JavaScriptCoding #WebDevelopment #JavaScriptBasics
ReactJS is arguably the most popular Javascript framework around for web development today. With more and more teams exploring and adopting React, here is TechTalks presentation elaborating fundamentals of React, in a code along session
React is a JavaScript library for building user interfaces that allows developers to create reusable UI components. It uses a virtual DOM for efficient re-rendering when data changes, and can render components on both the client-side and server-side. Key aspects of React include JSX syntax that resembles HTML, the component model for building encapsulated components, and tools like NPM, Webpack and Babel that help support React projects.
This document introduces React, describing it as a JavaScript library for building user interfaces by rendering components rather than mutating the DOM directly. It discusses how React uses a virtual DOM for fast re-rendering, building components instead of templates, and the use of JSX syntax to write HTML-like code. Components have state and props, and the whole app re-renders when state changes to guarantee updates.
In this Presentation all type of JS frameworks are discussed and by viewing this you can compare that which is the best JS framework in present time for different different purposes.
This document provides an introduction to ReactJS, including:
- Why React is simple, declarative, and allows building of composable components
- React's popularity, with over 900,000 downloads in the last month
- How React addresses issues with traditional web development through its use of virtual DOM and componentization
- An example component is demonstrated to show how to: render in JSX, make components dynamic and interactive through props and event handling, access the DOM through refs, and manage state.
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
This document provides an overview of React and Redux concepts including:
- React basics like components, props, state, and lifecycle methods
- Flux architecture and how data flows through actions, dispatcher, and stores
- Redux as an alternative to Flux that uses a single store updated by reducers in response to actions
- Additional React topics like JSX, propTypes, and using React with ES6 classes are also covered.
This document provides a summary of the key concepts and chapters covered in a book about React. It begins with a brief table of contents that outlines the 3 parts and 13 chapters of the book. Part 1 focuses on learning the basics of React, including introducing React, components, data flow, rendering, lifecycles, forms, and third-party libraries. Part 2 covers additional React topics like routing, testing, and integrating Redux. Part 3 introduces React application architecture including Redux and building React applications for both the web and native platforms like React Native.
ReactJS is arguably the most popular Javascript framework around for web development today. With more and more teams exploring and adopting React, here is TechTalks presentation elaborating fundamentals of React, in a code along session
React is a JavaScript library for building user interfaces that allows developers to create reusable UI components. It uses a virtual DOM for efficient re-rendering when data changes, and can render components on both the client-side and server-side. Key aspects of React include JSX syntax that resembles HTML, the component model for building encapsulated components, and tools like NPM, Webpack and Babel that help support React projects.
This document introduces React, describing it as a JavaScript library for building user interfaces by rendering components rather than mutating the DOM directly. It discusses how React uses a virtual DOM for fast re-rendering, building components instead of templates, and the use of JSX syntax to write HTML-like code. Components have state and props, and the whole app re-renders when state changes to guarantee updates.
In this Presentation all type of JS frameworks are discussed and by viewing this you can compare that which is the best JS framework in present time for different different purposes.
This document provides an introduction to ReactJS, including:
- Why React is simple, declarative, and allows building of composable components
- React's popularity, with over 900,000 downloads in the last month
- How React addresses issues with traditional web development through its use of virtual DOM and componentization
- An example component is demonstrated to show how to: render in JSX, make components dynamic and interactive through props and event handling, access the DOM through refs, and manage state.
Tutorial Videos: https://www.youtube.com/playlist?list=PLD8nQCAhR3tQ7KXnvIk_v_SLK-Fb2y_k_
Day 1 : Introduction to React, Babel and Webpack
Prerequisites of starting the workshop ( Basic understanding of Node & Express )
What is Virtual DOM?
What is React and why should we use it?
Install and set up React:
a-Using create-react-app
b-From scratch using Babel and Webpack. We will use Webpack Dev Server.
Day 2 : React Basic Concepts
Types of Components: Class-based and Functional based Components
Use of JSX
Parent, Child, and Nested Components
Difference between State and Props
Create and Handle Routes
Component Lifecycle Methods
Create a form and handling form inputs
Use of arrow functions and Spread Operator
Day 3: Advanced Concepts in React
Use of Refs
What are Higher Order Components( HOC )?
How to use HOC
Understanding Context in React
This document provides an overview of React and Redux concepts including:
- React basics like components, props, state, and lifecycle methods
- Flux architecture and how data flows through actions, dispatcher, and stores
- Redux as an alternative to Flux that uses a single store updated by reducers in response to actions
- Additional React topics like JSX, propTypes, and using React with ES6 classes are also covered.
This document provides a summary of the key concepts and chapters covered in a book about React. It begins with a brief table of contents that outlines the 3 parts and 13 chapters of the book. Part 1 focuses on learning the basics of React, including introducing React, components, data flow, rendering, lifecycles, forms, and third-party libraries. Part 2 covers additional React topics like routing, testing, and integrating Redux. Part 3 introduces React application architecture including Redux and building React applications for both the web and native platforms like React Native.
ReactJS is a JavaScript library for building user interfaces using reusable and interactive UI components. It uses a virtual DOM for rendering UI components and follows a unidirectional data flow architecture. Major companies using ReactJS include Facebook, Instagram, AirBnB, and Khan Academy. ReactJS advantages include its use of components, JSX syntax, and debugging tools. Components are the basic building blocks and use props, state, and lifecycles. Flux is a common architecture used with ReactJS that involves a central store for managing data in a unidirectional flow.
React is a JavaScript library created by Facebook and Instagram to build user interfaces. It allows developers to create fast user interfaces easily through components. React uses a virtual DOM to update the real DOM efficiently. Some major companies that use React include Facebook, Yahoo!, Airbnb, and Instagram. React is not a complete framework but rather just handles the view layer. It uses a one-way data binding model and components to build user interfaces.
This is an interactive PowerPoint presentation I made for my seminar at my workplace. It talks and illustrates how the JavaScript engine works when executing code. It also contains a step-by-step animation which demonstrates the usage of the JavaScript event loop.
Feel free to use and refer content. Copyrights reserved.
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It uses virtual DOM which improves performance and can render on both client and server. React encourages a component-based approach where UI is broken into independent reusable pieces that accept external data through properties. Components manage their own state which allows the UI to update over time in response to user input. This makes React code more predictable and easier to debug than traditional two-way data binding.
The document provides an introduction to React, a JavaScript library for building user interfaces. It discusses key React concepts like components, properties, state, one-way data flow, and JSX syntax. It also covers setting up a development environment with Create React App and shows how to create a basic React component with state. The target audience appears to be people new to React who want to learn the fundamentals.
React is a JavaScript library for building user interfaces that uses a virtual DOM for improved performance. It uses a one-way data flow and declarative components. The virtual DOM allows React to efficiently update the real DOM by only making necessary changes. Components in React encapsulate elements and can have state and props. JSX is recommended for writing React components and compiles to plain JavaScript.
The document provides an introduction and overview of ES6, React, and Redux. It begins with an in-depth section about new features and syntax in ES6, including variable types, arrow functions, modules, classes, and more. It then discusses React, explaining concepts like the virtual DOM, one-way data flow, JSX syntax, props, nested components, conditionals, and state/setState. Finally, it briefly introduces Redux and mentions using React components on the server and in mobile apps with React Native.
This document provides an overview of React including:
- React is a JavaScript library created by Facebook for building user interfaces
- It uses virtual DOM to efficiently re-render components on updates rather than entire page
- React supports ES6 features and uses classes, arrow functions, and other syntax
- Popular tools for React include Create React App for setting up projects and React Dev Tools for debugging
20180518 QNAP Seminar - Introduction to React NativeEric Deng
What is React Native?
How does React Native work?
Writing React Native
Expo
Components, props, and states
Component lifecycle
Declarative and imperative
Event handling
User input
Style
Layout
Data access
Publishing your Project
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
Angular is an open-source front-end web development platform for building dynamic single-page applications. It was developed and is maintained by Google. Traditional web applications run from the server, requiring the client to request pages from the server on each user interaction. Single-page applications handle requests and rendering on the client-side using JavaScript, only requiring the server when data needs processing or business logic execution. Angular has evolved through several versions since its initial release in 2010. It is now a TypeScript-based framework that supports progressive web apps and mobile development. Major companies like Google, PayPal, and Microsoft use Angular for its component-based architecture, cross-platform capabilities, and productivity benefits.
The document provides an overview of Java web applications and deployment using Apache Tomcat web application server. It discusses what a web container is, how Tomcat works as a web container, and how to install, run and configure Tomcat. It also describes how to create Java web applications that can be deployed as WAR files, and how to define servlets and mappings in the web deployment descriptor (web.xml). Finally, it shows how to create a simple web application and deploy it on Tomcat.
www.opitz-consulting.com
How do Angular and React compare? Can we compare them at all? Actually, it's like comparing apples to oranges, but even so, we have to compare them. As it turns out, both frameworks are a nice example of co-evolution. They aren't as different as they used to be a few years ago. After showing the key concepts of both frameworks, our experts Dr. Marius Hofmeister and Stephan Rauh presented a small list of criteria helping to decide when to use which at iJS Conference in Munich on 25/10/17.
This document provides an overview of JavaScript for students. It defines JavaScript, explains why and how it is used, and covers basic JavaScript concepts like comments, functions, and events. Some key points:
- JavaScript is a scripting language commonly used for web development to make pages dynamic and interactive. It runs in the browser rather than on servers.
- JavaScript can be used to validate forms, change content, hide/show elements, and more. Popular uses include adding interactivity to websites and building front-end frameworks.
- Code is inserted between <script> tags and can be placed in HTML <head> or <body>. Functions are blocks of reusable code defined with function keywords.
- Events
JavaScript is a scripting language that runs in web browsers. It allows for dynamic interactions and effects on web pages. JavaScript code can run on the client-side to process user input and update pages in real-time without reloading. It is commonly used with HTML and CSS to create interactive web applications. Some key points covered are that JavaScript is weakly typed, prototype-based, and runs directly in web browsers to enhance the user experience.
ReactJS is a JavaScript library for building user interfaces using reusable and interactive UI components. It uses a virtual DOM for rendering UI components and follows a unidirectional data flow architecture. Major companies using ReactJS include Facebook, Instagram, AirBnB, and Khan Academy. ReactJS advantages include its use of components, JSX syntax, and debugging tools. Components are the basic building blocks and use props, state, and lifecycles. Flux is a common architecture used with ReactJS that involves a central store for managing data in a unidirectional flow.
React is a JavaScript library created by Facebook and Instagram to build user interfaces. It allows developers to create fast user interfaces easily through components. React uses a virtual DOM to update the real DOM efficiently. Some major companies that use React include Facebook, Yahoo!, Airbnb, and Instagram. React is not a complete framework but rather just handles the view layer. It uses a one-way data binding model and components to build user interfaces.
This is an interactive PowerPoint presentation I made for my seminar at my workplace. It talks and illustrates how the JavaScript engine works when executing code. It also contains a step-by-step animation which demonstrates the usage of the JavaScript event loop.
Feel free to use and refer content. Copyrights reserved.
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It uses virtual DOM which improves performance and can render on both client and server. React encourages a component-based approach where UI is broken into independent reusable pieces that accept external data through properties. Components manage their own state which allows the UI to update over time in response to user input. This makes React code more predictable and easier to debug than traditional two-way data binding.
The document provides an introduction to React, a JavaScript library for building user interfaces. It discusses key React concepts like components, properties, state, one-way data flow, and JSX syntax. It also covers setting up a development environment with Create React App and shows how to create a basic React component with state. The target audience appears to be people new to React who want to learn the fundamentals.
React is a JavaScript library for building user interfaces that uses a virtual DOM for improved performance. It uses a one-way data flow and declarative components. The virtual DOM allows React to efficiently update the real DOM by only making necessary changes. Components in React encapsulate elements and can have state and props. JSX is recommended for writing React components and compiles to plain JavaScript.
The document provides an introduction and overview of ES6, React, and Redux. It begins with an in-depth section about new features and syntax in ES6, including variable types, arrow functions, modules, classes, and more. It then discusses React, explaining concepts like the virtual DOM, one-way data flow, JSX syntax, props, nested components, conditionals, and state/setState. Finally, it briefly introduces Redux and mentions using React components on the server and in mobile apps with React Native.
This document provides an overview of React including:
- React is a JavaScript library created by Facebook for building user interfaces
- It uses virtual DOM to efficiently re-render components on updates rather than entire page
- React supports ES6 features and uses classes, arrow functions, and other syntax
- Popular tools for React include Create React App for setting up projects and React Dev Tools for debugging
20180518 QNAP Seminar - Introduction to React NativeEric Deng
What is React Native?
How does React Native work?
Writing React Native
Expo
Components, props, and states
Component lifecycle
Declarative and imperative
Event handling
User input
Style
Layout
Data access
Publishing your Project
Getting started with the reactjs, basics of reactjs, introduction of reactjs, core concepts of reactjs and comparison with the other libraries/frameworks
Angular is an open-source front-end web development platform for building dynamic single-page applications. It was developed and is maintained by Google. Traditional web applications run from the server, requiring the client to request pages from the server on each user interaction. Single-page applications handle requests and rendering on the client-side using JavaScript, only requiring the server when data needs processing or business logic execution. Angular has evolved through several versions since its initial release in 2010. It is now a TypeScript-based framework that supports progressive web apps and mobile development. Major companies like Google, PayPal, and Microsoft use Angular for its component-based architecture, cross-platform capabilities, and productivity benefits.
The document provides an overview of Java web applications and deployment using Apache Tomcat web application server. It discusses what a web container is, how Tomcat works as a web container, and how to install, run and configure Tomcat. It also describes how to create Java web applications that can be deployed as WAR files, and how to define servlets and mappings in the web deployment descriptor (web.xml). Finally, it shows how to create a simple web application and deploy it on Tomcat.
www.opitz-consulting.com
How do Angular and React compare? Can we compare them at all? Actually, it's like comparing apples to oranges, but even so, we have to compare them. As it turns out, both frameworks are a nice example of co-evolution. They aren't as different as they used to be a few years ago. After showing the key concepts of both frameworks, our experts Dr. Marius Hofmeister and Stephan Rauh presented a small list of criteria helping to decide when to use which at iJS Conference in Munich on 25/10/17.
This document provides an overview of JavaScript for students. It defines JavaScript, explains why and how it is used, and covers basic JavaScript concepts like comments, functions, and events. Some key points:
- JavaScript is a scripting language commonly used for web development to make pages dynamic and interactive. It runs in the browser rather than on servers.
- JavaScript can be used to validate forms, change content, hide/show elements, and more. Popular uses include adding interactivity to websites and building front-end frameworks.
- Code is inserted between <script> tags and can be placed in HTML <head> or <body>. Functions are blocks of reusable code defined with function keywords.
- Events
JavaScript is a scripting language that runs in web browsers. It allows for dynamic interactions and effects on web pages. JavaScript code can run on the client-side to process user input and update pages in real-time without reloading. It is commonly used with HTML and CSS to create interactive web applications. Some key points covered are that JavaScript is weakly typed, prototype-based, and runs directly in web browsers to enhance the user experience.
JavaScript is a client-side scripting language that allows dynamic interactions and effects on web pages. It can be inserted directly into HTML code or linked via external .js files. The DOM (Document Object Model) represents an HTML or XML document as a tree structure, with nodes for elements, attributes, and text. This allows JavaScript to access and manipulate the content, structure, and styling of documents. Common JavaScript objects include String, Date, Array, and Math objects for manipulating text, dates, arrays of values, and mathematical operations respectively.
50 common web developer interview questions [2020 updated] [www.full stack....Alex Ershov
Containerization refers to the process of packaging an application and its dependencies into a standardized unit called a container. Containers allow applications to run reliably from one computing environment to another by abstracting away differences between environments. Common container platforms include Docker and Kubernetes, which provide tools for building, shipping and running distributed applications. Containers allow more efficient utilization of computing resources and easier management of applications compared to traditional virtual machines.
This document provides an overview of Module 2 of a course on Internet and Web Technology. It covers topics related to JavaScript, including:
- Programming fundamentals of JavaScript like variables, functions, and statements
- Different types of operators in JavaScript like arithmetic, comparison, logical, and assignment operators
- Defining and calling functions
- Using built-in functions like alert(), confirm(), and prompt()
- Best practices for writing JavaScript code
It is a JavaScript programming language e book which help you to boost up your Basic Concept and Help you to in hacking respect to Cross-Site Scripting Attack.
This document provides an overview of JavaScript including its history, key features, and comparisons to other languages. It also discusses important JavaScript concepts like objects, functions, events, and libraries like jQuery. Key topics covered include the window, document, location, and history objects, arrays, cookies, closures, inheritance, callbacks, and popular JavaScript libraries and frameworks.
This document discusses how crowdsourcing ideas and feedback within an integrated development environment (IDE) can speed up the software development process. It proposes collecting data on code usage patterns from developers and using that data to provide automated code completions, documentation, and help for common tasks. Error reports could also be crowdsourced and linked to existing solutions to help developers quickly resolve issues. The goal is to leverage collective intelligence and experience within the development community to reduce individual learning curves and speeds.
The slides I was using in my JavaScript Jump Start lecture, that took place in HIT on October 9th, 2013. You can watch my lecture at http://youtu.be/VYLL5xWc1Jc.
More information about the Java course I deliver can be found at java.course.lifemichael.com
More information about the PHP course I deliver can be found at php.course.lifemichael.com
More information about the FED course I deliver can be found at fed.course.lifemichael.com
More information about the Scala course I deliver can be found at scala.course.lifemichael.com
More information about the Android course I deliver can be found at android.course.lifemichael.com
More information about the Kotlin course I deliver can be found at kotlin.course.lifemichael.com
More information about the Swift course I deliver can be found at swift.course.lifemichael.com
More information about the C++ course I deliver can be found at cpp.course.lifemichael.com
More information about the Go course I deliver can be found at go.course.lifemichael.com
More information about the CSS course I deliver can be found at css.course.lifemichael.com
More information about the C# course I deliver can be found at csharp.course.lifemichael.com
More information about the Python course I deliver can be found at python.course.lifemichael.com
More information about the Angular course I deliver can be found at angular.course.lifemichael.com
More information about the Node.js course I deliver can be found at nodejs.course.lifemichael.com
More information about the Fullstack Development course I deliver can be found at fullstack.course.lifemichael.com
jquery summit presentation for large scale javascript applicationsDivyanshGupta922023
The document discusses different patterns for organizing JavaScript applications, including the module pattern and MVC frameworks. It provides examples of implementing the module pattern in jQuery, Dojo, YUI, and ExtJS. It also covers MVC frameworks like Backbone.js, AngularJS, and Ember and discusses how to convert existing code to an MVC structure.
JavaScript is a client-side scripting language that is commonly used to create dynamic and interactive effects on web pages. It resides in the browser and is used to enhance user interfaces and experiences on websites. JavaScript code is made up of statements that are written within script tags. Functions are blocks of code in JavaScript that perform specific tasks, and variables are used to store and retrieve values. jQuery is a JavaScript library that simplifies client-side scripting by using CSS selectors and providing methods to easily manipulate HTML elements and run animations. Both JavaScript and jQuery code is typically linked from the HTML head or an external .js file and placed above other scripts.
JavaScript was designed to add interactivity to HTML pages. It is a scripting language that is usually embedded directly into HTML pages and allows for dynamic text, event handling, reading/writing HTML elements, and validating form data. JavaScript supports both client-side and server-side scripting and was originally developed by Netscape under the name LiveScript before being renamed. It provides programming capabilities to HTML authors and allows for dynamic content, user interaction, and validation without server requests.
This document provides information about an upcoming backend development bootcamp organized by Google Developer Student Clubs (GDSC). It outlines the topics that will be covered, including JavaScript, Node.js, Express, MongoDB, and building a hands-on idea box project. It also shares details about past GDSC events like Android Study Jams where students submitted apps and winners were selected. Presenters are introduced who will teach various sessions over the course of the bootcamp, providing overviews of the topics they will cover like intro to JavaScript, servers, REST APIs, and using databases.
You are assigned to work on a JavaScript project as a junior web designer. The document provides questions and answers related to JavaScript syntax, objects, methods, and other concepts. It covers topics like loops, variables, arrays, functions, conditional statements, and more. The questions will help you learn about properly using JavaScript in your project.
The document provides an outline and introduction to JavaScript concepts including variables, functions, conditions, loops, pop-up boxes, objects, and the Document Object Model (DOM). It discusses tasks performed by client-side scripts like form validation, event handling, and dynamic page updates. It also compares client-side and server-side scripting, noting that client-side scripts execute on the browser and allow for interactivity but cannot access local files or databases.
This document provides an introduction and overview of JavaScript. It discusses that JavaScript is a client-side scripting language that can be inserted into HTML pages and run by web browsers to provide interactive and dynamic features. It covers JavaScript basics like data types, variables, operators, functions, and events. It also explains how to write JavaScript code directly in HTML pages or externally and shows examples of built-in functions and how to create user-defined functions.
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
This document provides an overview of designing complex applications using HTML5 and KnockoutJS. It discusses HTML5 and why it is useful, introduces JavaScript and frameworks like KnockoutJS and SammyJS that help manage complexity. It also summarizes several JavaScript libraries and patterns including the module pattern, revealing module pattern, and MV* patterns. Specific libraries and frameworks discussed include RequireJS, AmplifyJS, UnderscoreJS, and LINQ.js. The document concludes with a brief mention of server-side tools like ScriptSharp.
Constructors cannot be made final as they are needed to create object instances and initialize class data. Constructors are similar to methods but cannot be directly invoked via method calls. The APK file format is an Android application package used for distribution and installation of Android apps. It is a zip file containing compiled code, resources, manifest, and other assets. Java is a popular object-oriented programming language that is portable and platform independent due to its compile-once-run-anywhere nature.
Ähnlich wie JavaScript Interview Questions with Answers (20)
Reimagining Your Library Space: How to Increase the Vibes in Your Library No ...Diana Rendina
Librarians are leading the way in creating future-ready citizens – now we need to update our spaces to match. In this session, attendees will get inspiration for transforming their library spaces. You’ll learn how to survey students and patrons, create a focus group, and use design thinking to brainstorm ideas for your space. We’ll discuss budget friendly ways to change your space as well as how to find funding. No matter where you’re at, you’ll find ideas for reimagining your space in this session.
A review of the growth of the Israel Genealogy Research Association Database Collection for the last 12 months. Our collection is now passed the 3 million mark and still growing. See which archives have contributed the most. See the different types of records we have, and which years have had records added. You can also see what we have for the future.
Chapter wise All Notes of First year Basic Civil Engineering.pptxDenish Jangid
Chapter wise All Notes of First year Basic Civil Engineering
Syllabus
Chapter-1
Introduction to objective, scope and outcome the subject
Chapter 2
Introduction: Scope and Specialization of Civil Engineering, Role of civil Engineer in Society, Impact of infrastructural development on economy of country.
Chapter 3
Surveying: Object Principles & Types of Surveying; Site Plans, Plans & Maps; Scales & Unit of different Measurements.
Linear Measurements: Instruments used. Linear Measurement by Tape, Ranging out Survey Lines and overcoming Obstructions; Measurements on sloping ground; Tape corrections, conventional symbols. Angular Measurements: Instruments used; Introduction to Compass Surveying, Bearings and Longitude & Latitude of a Line, Introduction to total station.
Levelling: Instrument used Object of levelling, Methods of levelling in brief, and Contour maps.
Chapter 4
Buildings: Selection of site for Buildings, Layout of Building Plan, Types of buildings, Plinth area, carpet area, floor space index, Introduction to building byelaws, concept of sun light & ventilation. Components of Buildings & their functions, Basic concept of R.C.C., Introduction to types of foundation
Chapter 5
Transportation: Introduction to Transportation Engineering; Traffic and Road Safety: Types and Characteristics of Various Modes of Transportation; Various Road Traffic Signs, Causes of Accidents and Road Safety Measures.
Chapter 6
Environmental Engineering: Environmental Pollution, Environmental Acts and Regulations, Functional Concepts of Ecology, Basics of Species, Biodiversity, Ecosystem, Hydrological Cycle; Chemical Cycles: Carbon, Nitrogen & Phosphorus; Energy Flow in Ecosystems.
Water Pollution: Water Quality standards, Introduction to Treatment & Disposal of Waste Water. Reuse and Saving of Water, Rain Water Harvesting. Solid Waste Management: Classification of Solid Waste, Collection, Transportation and Disposal of Solid. Recycling of Solid Waste: Energy Recovery, Sanitary Landfill, On-Site Sanitation. Air & Noise Pollution: Primary and Secondary air pollutants, Harmful effects of Air Pollution, Control of Air Pollution. . Noise Pollution Harmful Effects of noise pollution, control of noise pollution, Global warming & Climate Change, Ozone depletion, Greenhouse effect
Text Books:
1. Palancharmy, Basic Civil Engineering, McGraw Hill publishers.
2. Satheesh Gopi, Basic Civil Engineering, Pearson Publishers.
3. Ketki Rangwala Dalal, Essentials of Civil Engineering, Charotar Publishing House.
4. BCP, Surveying volume 1
Leveraging Generative AI to Drive Nonprofit InnovationTechSoup
In this webinar, participants learned how to utilize Generative AI to streamline operations and elevate member engagement. Amazon Web Service experts provided a customer specific use cases and dived into low/no-code tools that are quick and easy to deploy through Amazon Web Service (AWS.)
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
How to Setup Warehouse & Location in Odoo 17 InventoryCeline George
In this slide, we'll explore how to set up warehouses and locations in Odoo 17 Inventory. This will help us manage our stock effectively, track inventory levels, and streamline warehouse operations.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
2. https://akdeepknowledge.com
JavaScript Interview Questions
Interview Questions
1. What do you understand about JavaScript? 4
2. What’s the difference between JavaScript and Java? 4
3. What are the different types of data available in JavaScript? 4
4. What are the features of JavaScript? 5
5. What benefits does JavaScript offer compared to other web technologies? 5
6. How can an object be created in JavaScript? 5
7. How can an array be created in JavaScript? 6
8. What are some of the pre-existing methods available in JavaScript? 6
9. What are the scopes of a variable in JavaScript? 6
10. What is the ‘this’ keyword in JavaScript? 6
11. What are the conventions of naming a variable in JavaScript? 7
12. What is Callback in JavaScript? 7
13. How do you debug a JavaScript code? 7
14. What distinguishes a Function declaration and Function expression? 8
15. How can you include JavaScript code in an HTML file? 8
16. What do you understand about cookies? 8
17. How would you create a cookie? 9
18. How would you read a cookie? 9
19. How would you delete a cookie? 9
20. What’s the difference between let and var? 10
21. What are Closures in JavaScript? 10
22. What are the arrow functions in JavaScript? 10
23. What are the various methods to access an HTML element in JavaScript code? 11
24. What are the methods for defining a variable in JavaScript? 11
25. What are Imports and Exports in JavaScript? 11
26. What is the differences between Document and Window in JavaScript? 12
27. What are some of the JavaScript frameworks and their purposes? 12
28. What is the difference between Undefined and Undeclared in JavaScript? 12
29. What is the differences between Undefined and Null in JavaScript? 13
30. What is the difference between Session storage and Local storage? 13
31. What are the different data types that exist in JavaScript? 14
32. What is the ‘this’ keyword in JavaScript? 14
33. What is the difference between Call and Apply? (explain in detail with examples) 14
34. What are the scopes of a variable in JavaScript? 15
35. What are the arrow functions in JavaScript? 15
3. https://akdeepknowledge.com
36. Explain Hoisting in JavaScript. (with examples) 15
37. Difference between “==” and “===” operators (with examples) 16
38. Difference between var and let keyword 16
39. Implicit Type Coercion in JavaScript (in detail with examples) 17
40. Is JavaScript a statically typed or a dynamically typed language? 17
41. NaN property in JavaScript 17
42. Passed by value and passed by reference 18
43. Immediately Invoked Function in JavaScript 18
44. Characteristics of JavaScript strict mode 19
45. Higher Order Functions (with examples) 19
46. Self-Invoking Functions 20
47. Difference between exec() and test() methods 20
49. Advantages of using External JavaScript 22
50. What are object prototypes? 22
51. Types of errors in JavaScript 23
52. What is memorization? 23
53. Recursion in a programming language 24
54. Use of a constructor function (with examples) 25
4. https://akdeepknowledge.com
1. What do you understand about JavaScript?
JavaScript is a versatile programming language is mainly utilized to enhance the interactivity of web
pages. Unlike static HTML and CSS, JavaScript adds dynamic elements to websites, enabling features
like interactive forms, animations, and real-time updates without reloading the page.
2. What’s the difference between JavaScript and Java?
Aspect JavaScript Java
Type Scripting language Object-oriented programming language
Platform Client-side scripting, runs in browsers Platform-independent, runs on Java Virtual Machine
Syntax C-like syntax C/C++-like syntax
Usage Web development, client-side scripting General-purpose programming, server-side applications
Origin Developed by Netscape in 1995 Developed by Sun Microsystems in 1995
3. What are the different types of data available in JavaScript?
JavaScript supports several data types following.
• Primitive types: number, string, boolean, null, undefined, symbol.
• Reference types: object (arrays, functions, objects).
5. https://akdeepknowledge.com
4. What are the features of JavaScript?
JavaScript offers a wide range of features are.
• Dynamic typing
• Prototypal inheritance
• First-class functions
• Closures
• Asynchronous programming with Promises
• Event-driven programming
5. What benefits does JavaScript offer compared to other web technologies?
Advantages of JavaScript
• Cross-platform compatibility
• Rich interface and user experience
• Reduced server load with client-side processing
• Enhanced interactivity and responsiveness
• Large ecosystem with numerous libraries and frameworks
6. How can an object be created in JavaScript?
In JavaScript, you can create an object using either object literals or constructor functions.
// Using object literals
let myObject = {
key1: value1,
key2: value2,
// Additional key-value pairs
};
// Using constructor functions
function Person(name, age) {
this.name = name;
this.age = age;
}
let person1 = new Person('John', 30);
6. https://akdeepknowledge.com
7. How can an array be created in JavaScript?
In JavaScript, arrays can be created using array literals or the Array constructor.
// Using array literals
let myArray = [element1, element2, ...];
// Using the Array constructor
let myArray = new Array(element1, element2, ...);
8. What are some of the pre-existing methods available in JavaScript?
JavaScript provides a variety of built-in methods for different data types and objects. Some common
ones include:
• Array: push(), pop(), shift(), unshift(), splice()
• String: charAt(), toUpperCase(), toLowerCase(), split(), substring()
• Object: hasOwnProperty(), toString(), valueOf()
• Math: random(), round(), floor(), ceil(), sqrt()
9. What are the scopes of a variable in JavaScript?
In JavaScript, variables can have either global or local scope. Global variables are accessible
throughout the entire program, while local variables are limited to the function in which they are
declared.
10. What is the ‘this’ keyword in JavaScript?
The “this” keyword in JavaScript refers to the object to which it belongs. Its value is determined by
how a function is called and can vary depending on the context of the function invocation.
7. https://akdeepknowledge.com
11. What are the conventions of naming a variable in JavaScript?
In JavaScript, variable names follow certain conventions.
• Begin with a letter, underscore, or dollar sign.
• Variables can contain letters, digits, underscores, and dollar signs in JavaScript.
• Cannot use reserved words or keywords.
12. What is Callback in JavaScript?
A callback in JavaScript is a function passed as an argument to another function, which is then
executed after a certain event or operation. Callbacks are commonly used in asynchronous
programming to handle tasks such as fetching data from a server or executing code after a timer
expires.
13. How do you debug a JavaScript code?
JavaScript code can be debugged using various tools and techniques are following.
• Browser developer tools like Chrome DevTools or Firefox Developer Tools, which offer
features like breakpoints, stepping through code, and inspecting variables.
• console.log() statements to log information to the browser console.
• Debugging tools provided by integrated development environments (IDEs) like Visual
Studio Code or WebStorm.
8. https://akdeepknowledge.com
14. What distinguishes a Function declaration and Function expression?
Aspect Function Declaration Function Expression
Syntax
Starts with the function keyword followed
by a name
Can be named or anonymous, starts
with function keyword
Hoisting
Entire function is hoisted to the top of the
scope
Only the variable declaration is hoisted, not the
function
Usage Can be called before its declaration Cannot be called before its definition
Example
function myFunction() { /*
function body */ }
const myFunction = function() { /*
function body */ };
15. How can you include JavaScript code in an HTML file?
JavaScript code can be added to an HTML file in several ways.
• Inline: Using the <script> tag directly in the HTML file.
• External file: Linking an external JavaScript file using the <script> tag’s src attribute.
• Event attributes: Adding JavaScript code directly to HTML elements using event
attributes like onclick or onload.
16. What do you understand about cookies?
Cookies are tiny bits of information that websites store on the user’s browser. They are commonly
used for tracking user sessions, storing user preferences, and implementing features like shopping
carts in e-commerce websites.
9. https://akdeepknowledge.com
17. How would you create a cookie?
In JavaScript, you can create a cookie by setting a value to document.cookie.
Here’s an example.
document.cookie = "username=John";
This code snippet sets a cookie named "username" with the value "John".
18. How would you read a cookie?
You can read a cookie using the document.cookie property.
Here’s an example of reading the “username” cookie:
let username = document.cookie.split('; ').find(row => row.startsWith('username')).split('=')[1];
This retrieves the value of the "username" cookie.
19. How would you delete a cookie?
To delete a cookie, you can set its expiration date to a past date.
Here’s an example.
document.cookie = "username=John; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
This sets the "username" cookie to expire immediately, effectively deleting it.
10. https://akdeepknowledge.com
20. What’s the difference between let and var?
Aspect let var
Scope
Block scope (limited to the block where
it’s defined)
Function scope (limited to the function where
it’s defined)
Hoisting Not hoisted Hoisted to the top of its scope
Re-
declaration
Cannot be re-declared within the same
scope
Can be re-declared within the same scope
Example let x = 10; var y = 20;
21. What are Closures in JavaScript?
Closures in JavaScript refer to the ability of a function to retain access to its surrounding scope even
after the function has finished executing. This allows the function to access and manipulate variables
from its enclosing scope.
22. What are the arrow functions in JavaScript?
Arrow functions provide a more concise way to express function expressions in JavaScript, making
the code easier to read and write. They have a more compact syntax compared to traditional
function expressions and lexically bind the this value, meaning they inherit the this value from the
surrounding code.
Example of an arrow function
javascriptCopy code
const add = (a, b) => a + b;
11. https://akdeepknowledge.com
23. What are the various methods to access an HTML element in JavaScript code?
HTML elements can be accessed in JavaScript using various methods:
• By ID: document.getElementById()
• By class name: document.getElementsByClassName()
• By tag name: document.getElementsByTagName()
• Using CSS selectors: document.querySelector() or document.querySelectorAll()
• By name attribute: document.getElementsByName()
24. What are the methods for defining a variable in JavaScript?
In JavaScript, you can define variables using the var, let, or const keywords.
• var is function-scoped and can be re-declared and reassigned.
• let is block-scoped, can be reassigned, but not re-declared in the same scope.
• const is also block-scoped but cannot be reassigned or re-declared.
25. What are Imports and Exports in JavaScript?
Imports and exports are part of the ES6 module system in JavaScript, allowing developers to
organize code into separate files and reuse functionality across multiple files.
• import is used to import functionalities from other modules.
• export is used to export functionalities from a module to make them available for
other modules to import.
12. https://akdeepknowledge.com
26. What is the differences between Document and Window in JavaScript?
Aspect Document Window
Scope Document object model (DOM) Browser window object
Access Represents the content of a webpage Represents the browser window
itself
Properties Contains properties like body, title, URL Contains properties
like location, history, navigator
Methods Contains methods
like getElementById(), querySelector()
Contains methods
like alert(), open(), close()
27. What are some of the JavaScript frameworks and their purposes?
JavaScript frameworks like React, Angular, and Vue.js are popular for building modern web
applications. They provide tools and libraries to simplify development tasks, handle complex user
interfaces, and manage application state efficiently.
28. What is the difference between Undefined and Undeclared in JavaScript?
Aspect Undefined Undeclared
Definition Variable is declared but not
initialized
Variable is not declared or defined
Example let x; console.log(x);
// undefined
console.log(y); // ReferenceError: y is
not defined
13. https://akdeepknowledge.com
29. What is the differences between Undefined and Null in JavaScript?
Aspect Undefined Null
Definition
Variable has been declared but not assigned
a value
Variable explicitly assigned the
value null
Example
let x; console.log(x); //
undefined
let y = null; console.log(y); //
null
30. What is the difference between Session storage and Local storage?
Aspect Session Storage Local Storage
Scope Limited to the current session Persists even after the browser is closed
Expiration Cleared when the session ends Persists until explicitly cleared
Storage limit Typically larger than cookies Typically larger than cookies
14. https://akdeepknowledge.com
31. What are the different data types that exist in JavaScript?
JavaScript supports several data types, including.
• Primitive types: number, string, boolean, null, undefined, symbol
• Reference types: object (arrays, functions, objects)
32. What is the ‘this’ keyword in JavaScript?
The “this” keyword in JavaScript refers to the object to which it belongs. Its value is determined by
how a function is called and can vary depending on the context of the function invocation.
33. What is the difference between Call and Apply? (explain in detail with examples)
Aspect Call Method Apply Method
Syntax function.call(thisArg, arg1, arg2)
function.apply(thisArg,
[argsArray])
Arguments Accepts individual arguments Accepts arguments as an array
Example func.call(obj, arg1, arg2) func.apply(obj, [arg1, arg2])
15. https://akdeepknowledge.com
34. What are the scopes of a variable in JavaScript?
In JavaScript, variables have either global or local scope. Global variables are accessible throughout
the entire program, while local variables are limited to the function in which they are declared.
35. What are the arrow functions in JavaScript?
Arrow functions provide a concise method for writing function expressions in JavaScript. They
provide a shorter syntax compared to traditional function expressions and lexically bind this value,
making it easier to access the surrounding context.
36. Explain Hoisting in JavaScript. (with examples)
Hoisting is a mechanism in JavaScript where variables and function declarations are moved to the
top of their containing scope during the compile phase. This enables variables and functions to be
utilized before they are declared.
Example
console.log(x); // Output: undefined var x = 5;
In the above example, the variable x is hoisted to the top of its scope, but its value is not assigned
until the line where it’s declared. Therefore, console.log(x) outputs undefined.
16. https://akdeepknowledge.com
37. Difference between “==” and “===” operators (with examples)
Aspect == Operator === Operator
Equality Check Checks for equality after type coercion
Checks for strict equality (no type
coercion)
Example 0 == '0' // true 0 === '0' // false
38. Difference between var and let keyword
Aspect var Keyword let Keyword
Scope Function-scoped Block-scoped
Hoisting Hoisted to the top of the function Not hoisted
Re-declaration
Can be re-declared within the same
scope
Cannot be re-declared within the
same scope
17. https://akdeepknowledge.com
39. Implicit Type Coercion in JavaScript (in detail with examples)
Implicit type coercion in JavaScript refers to the automatic conversion of one data type to another
during operations.
Example
console.log(1 + '2'); // Output: '12' (number is coerced to string)
console.log('2' - 1); // Output: 1 (string is coerced to number)
In the first example, the number 1 is coerced into a string and concatenated with '2'. In the second
example, the string '2' is coerced into a number and subtracted from 1.
40. Is JavaScript a statically typed or a dynamically typed language?
JavaScript is a dynamically typed language. This means that variables in JavaScript can hold values of
any data type, and their data types are determined at runtime rather than at compile time.
41. NaN property in JavaScript
NaN stands for “Not-a-Number” and is a special value in JavaScript used to represent an
unrepresentable value resulting from an arithmetic operation. It is returned when a mathematical
operation is performed on a non-numeric value.
Example
console.log(0 / 0); // Output: NaN
18. https://akdeepknowledge.com
42. Passed by value and passed by reference
In JavaScript, primitive data types (like numbers and strings) are passed by value, while objects and
arrays are passed by reference.
• Passed by value: A copy of the variable’s value is passed to the function.
• Passed by reference: A reference to the variable’s memory location is passed to the
function.
Example
let num = 10;
function changeNum(val) {
val = 20;
}
changeNum(num);
console.log(num); // Output: 10 (unchanged)
let arr = [1, 2, 3];
function changeArr(arr) {
arr.push(4);
}
changeArr(arr);
console.log(arr); // Output: [1, 2, 3, 4] (modified)
In the first example, num remains unchanged because it’s passed by value. In the second
example, arr is modified because it’s passed by reference.
43. Immediately Invoked Function in JavaScript
An Immediately Invoked Function Expression (IIFE) is a JavaScript function that is executed
immediately after it is defined. It is typically used to create a private scope and avoid polluting the
global namespace with variables.
Example:
(function() { // IIFE body console.log('This is an IIFE'); })();
In this example, the function is defined and immediately invoked using parentheses ( ) around the
function declaration.
19. https://akdeepknowledge.com
44. Characteristics of JavaScript strict mode
JavaScript strict mode is a feature that enforces stricter parsing and error handling in JavaScript.
Some characteristics of strict mode following.
• Disallows the use of undeclared variables.
• Throws errors for assignments to non-writable properties.
• Prevents the use of with statement.
• Disallows the use of arguments.callee and arguments.caller.
• Throws errors for duplicate property names in objects.
Strict mode is enabled by adding the directive 'use strict'; at the beginning of a script or
function.
45. Higher Order Functions (with examples)
Higher Order Functions in JavaScript are functions that either take other functions as arguments or
return functions as results.
Example
// Function taking another function as argument
function higherOrderFunction(callback) {
callback();
}
// Function returning another function
function createMultiplier(factor) {
return function(num) {
return num * factor;
};
}
// Usage of higher order functions
higherOrderFunction(function() {
console.log('This is a callback function');
});
const double = createMultiplier(2);
console.log(double(5)); // Output: 10
20. https://akdeepknowledge.com
In this example, higherOrderFunction takes a callback function as an argument,
and createMultiplier returns a function that multiplies its argument by a factor.
46. Self-Invoking Functions
A self-invoking function, also known as an immediately-invoked function expression (IIFE), is a
function that is automatically executed as soon as it is defined. It is wrapped inside parentheses (
) to make it an expression and then immediately invoked using an additional pair of parentheses (
).
Example.
(function() { console.log("This is a self-invoking function!"); })();
In this example, the function is defined and invoked immediately, printing the message “This is a self-
invoking function!” to the console.
47. Difference between exec() and test() methods
The exec() and test() methods are both methods of the JavaScript RegExp object used for working
with regular expressions.
exec(): Executes a search for a match in a specified string. If a match is found, it returns an array
containing the matched text, along with information about the match. If no match is found, it
returns null.
Example
let str = "Hello World!";
let pattern = /Hello/;
console.log(pattern.exec(str)); // Output: ["Hello", index: 0, input: "Hello World!", groups: undefined]
test(): Tests for a match in a string. It returns true if a match is found, otherwise false.
21. https://akdeepknowledge.com
Example
let str = "Hello World!";
let pattern = /Hello/;
console.log(pattern.test(str)); // Output: true
In summary, exec() returns details about the match, while test() simply returns a boolean
indicating whether a match exists.
48. Currying in JavaScript (with examples)
Currying is a technique in functional programming where a function with multiple arguments is
transformed into a sequence of functions, each taking a single argument. This allows for partial
application of the function, which can be useful for creating reusable and composable functions.
Example.
// Without currying
function add(a, b, c) {
return a + b + c;
}
console.log(add(1, 2, 3)); // Output: 6
// With currying
function curryAdd(a) {
return function(b) {
return function(c) {
return a + b + c;
}
}
}
console.log(curryAdd(1)(2)(3)); // Output: 6
In the curried version, curryAdd returns a series of functions, each taking one argument and
returning another function until all arguments are collected and the final result is calculated.
22. https://akdeepknowledge.com
49. Advantages of using External JavaScript
Using external JavaScript files has several advantages.
• Separation of concerns: Keeps HTML and JavaScript code separate, making code
organization and maintenance easier.
• Caching: External JavaScript files can be cached by the browser, reducing page load
times for subsequent visits.
• Reuse: External JavaScript files can be reused across multiple HTML files, promoting
code reusability.
• Improved maintainability: Changes to JavaScript code can be made in a single file,
which reflects across all HTML files that reference it.
50. What are object prototypes?
In JavaScript, every object has a prototype, which serves as a template for the object. The prototype
contains properties and methods that are accessible to all instances of the object. When a property
or method is accessed on an object, JavaScript first checks if the object has that property or method.
If not found, it looks up the prototype chain until it finds it.
Example.
// Creating an object with a prototype
let animal = {
type: 'Animal',
sound: function() {
console.log('Makes a sound');
}
};
// Creating an instance of the object
let cat = Object.create(animal);
cat.type = 'Cat';
console.log(cat.type); // Output: 'Cat'
cat.sound(); // Output: 'Makes a sound'
In this example, cat inherits the properties and methods from the animal prototype object.
23. https://akdeepknowledge.com
51. Types of errors in JavaScript
JavaScript errors can be categorized into several types.
• Syntax errors: Occur when the JavaScript engine encounters code that violates the
language syntax rules. These errors prevent the code from executing and are typically
detected during the parsing phase.
• Runtime errors: Occur during the execution of the code when an operation cannot be
performed as expected. Examples include accessing undefined variables, type errors,
and division by zero.
• Logical errors: Occur when the code does not produce the expected output due to
incorrect logic or algorithmic mistakes. These errors are often more subtle and may not
result in immediate failures or exceptions.
• Reference errors: Occur when trying to access a variable or function that is not
defined or is out of scope. This typically happens when attempting to access properties
of undefined or null values.
52. What is memorization?
Memorization is an optimization technique used in computer programming to speed up function
execution by caching the results of expensive function calls and returning the cached result when
the same inputs occur again.
Example
function memoize(func) {
let cache = {};
return function(...args) {
let key = JSON.stringify(args);
if (!(key in cache)) {
cache[key] = func.apply(this, args);
}
return cache[key];
};
}
// Example function to be memoized
function expensiveOperation(n) {
console.log('Performing expensive operation...');
return n * 2;
}
24. https://akdeepknowledge.com
let memoizedOperation = memoize(expensiveOperation);
console.log(memoizedOperation(5)); // Output: Performing expensive operation... 10
console.log(memoizedOperation(5)); // Output: 10 (cached result)
In this example, the expensiveOperation function’s results are cached based on the input
argument n, and subsequent calls with the same argument retrieve the cached result instead of
recomputing it.
53. Recursion in a programming language
Recursion is a programming technique where a function calls itself to solve a problem. This process
continues until a base case is reached, which stops the recursive calls. Recursion is particularly useful
for solving problems that can be broken down into smaller, similar subproblems.
Example of a recursive function to calculate factorial.
function factorial(n) {
if (n === 0 || n === 1) {
return 1; // Base case: factorial of 0 or 1 is 1
} else {
return n * factorial(n - 1); // Recursive call
}
}
console.log(factorial(5)); // Output: 120
In this example, the factorial function calls itself with a smaller input (n - 1) until it reaches the
base case (n === 0 or n === 1), at which point it returns 1.
25. https://akdeepknowledge.com
54. Use of a constructor function (with examples)
Constructor functions in JavaScript are used to create multiple instances of objects with similar
properties and methods. They are typically defined with a capitalized name to distinguish them from
regular functions.
Example of a constructor function to create objects representing cars.
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
// Creating instances of Car objects
let car1 = new Car('Toyota', 'Corolla', 2020);
let car2 = new Car('Honda', 'Civic', 2018);
console.log(car1); // Output: Car { make: 'Toyota', model: 'Corolla', year: 2020 }
console.log(car2); // Output: Car { make: 'Honda', model: 'Civic', year: 2018 }
In this example, the Car constructor function is used to create two instances (car1 and car2)
of Car objects with different properties.
26. https://akdeepknowledge.com
Updated Questions 👇
Updated Post Link: https://akdeepknowledge.com/javascript-interview-coding-questions/
More Interview Questions 👇
• Python: https://akdeepknowledge.com/python-programming-interview-questions/
• SQL: https://akdeepknowledge.com/important-sql-interview-questions/
• Linux: https://akdeepknowledge.com/linux-commands-for-devops-interview-questions/
• Data Bricks: https://akdeepknowledge.com/databricks-interview-questions-and-answers/
Article And Free Course Tutorials 👇
Visit Blog Website: https://akdeepknowledge.com
Visit Coding Website:
Follow on My social media 👇
Subscribe YouTube Channel: https://www.youtube.com/@akdeepknowledge/videos
Facebook Page: https://www.facebook.com/ArsalanKhatri184
LinkedIn Group: https://www.linkedin.com/groups/9305818/
SlideShare: https://www.slideshare.net/ArsalanKhatri4
Medium: https://medium.com/@Arsalan_Khatri
CodePen: https://codepen.io/AK-Deep-Knowledge
GitHub: https://github.com/arsalankhatri184