Karteikarten
Interview Questions
Karten in diesem Stapel (39)
- 1Explain equality in JavaScript!
- 2What is Scope in JavaScript?Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's scoped variables.
Example: In JavaScript, each function gets its own scope. - 3What is NPM?NPM stands for Node Package Manager. It’s the world largest software library. it is used to publish, discover, install, and develop node programs.
Example: express NPM back end web application framework for Node.js - 4Explain Null and Undefined in JavaScriptSomething hasn't been initialized: undefined.
Something is currently unavailable: null.
In JavaScript each variable is created is undefined unless we assign value, if we want value to be null we should assign it explicitly - 5What is DOM?With the Document Object Model, programmers can create and build documents, navigate their structure, and add, modify, or delete elements and content. The DOM specifies interfaces which may be used to manage XML or HTML documents.
- 6What is the difference between procedural and object-oriented programming?Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another.
On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables .Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal. - 7What is the difference between span and div?div is a block element
span is inline element - 8How to compare two objects in JavaScript?Two non-primitive values, like objects (including function and array) held by reference, so both == and === comparisons will simply check whether the references match, not anything about the underlying values.
- 9What is CSS selectors? Name some.A CSS selector is the part of a CSS rule set that actually selects the content you want to style.
Consider some types of CSS selectors:
Universal selector: *
Element type selector: ul, td
ID Selector: #id
Class selector: .box - 10What is HTML5 Web Storage? Explain localStorage and sessionStorage.With HTML5, web pages can store data locally within the user’s browser. The data is stored in name/value pairs, and a web page can only access data stored by itself.
- 11Differences between localStorage and sessionStorage regarding lifetimeData stored through localStorage is permanent: it does not expire and remains stored on the user’s computer until a web app deletes it or the user asks the browser to delete it.
sessionStorage has the same lifetime as the top-level window or browser tab in which the data got stored. When the tab is permanently closed, any data stored through sessionStorage is deleted. - 12Differences between localStorage and sessionStorage regarding storage scope:Both forms of storage are scoped to the document origin so that documents with different origins will never share the stored objects.
sessionStorage is also scoped on a per-window basis. Two browser tabs with documents from the same origin have separate sessionStorage data.
Unlike in localStorage, the same scripts from the same origin can't access each other's sessionStorage when opened in different tabs. - 13Explain difference between: function Person(){}, var person = Person(), and var person = new Person()?Function Person() {} – declares a new function named Person.
Var person = Person() - Declares a new function, Person, invokes it and then assigns the return value to the variable person.
Var person = new Person() – the “new” keyword means that Person is an object constructor function which returns a new object instance. - 14What are callbacks?A callback is a function that is passed to another function as variable and will be executed after another function gets executed. We use callbacks to handle asynchronous code.
In JavaScript, functions are treated as first-class citizens, they can be used as an argument of another function, can be returned by another function and can be used as a property of an object. - 15How does the “this” keyword work? Provide some code examples“This” is a save keyword in JavaScript, “this” keyword refers to the current object in a method or constructor, the value of “this” keyword will always depend on the object that is invoking the function.
- 16What is GOD class and why should we avoid it?The God object is a part of the code smell group and it is a kind of object that knows too much or does too much. That means a huge class in terms of number of lines of code. It is very famous in bad programming because it creates tight coupling and increases the challenges in the code maintainability.
- 17What is Hoisting in JavaScript?
- 18What is Closure in JavaScript? Provide an exampleClosures is an ability of a function to remember the variables and functions that are declared in its outer scope. closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.
(every time we create an inner function that access the outer function variables and function we have/create a closure) - 19What is recursion in a programming languageRecursion is a technique to iterate over an operation by having a function call itself repeatedly until it arrives at a result.
Recursion is made for solving problems that can be broken down into smaller, repetitive problems. It is especially good for working on things that have many possible branches and are too complex for an iterative approach. - 20Is JavaScript a statically typed or a dynamically typed language?JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during run-time in contrast to statically typed language, where the type of a variable is checked during compile-time.
- 21What is NaN Property in JavaScript?NaN property represents “Not-a-Number” value. It indicates a value which is not a legal number. typeof of a NaN will return a Number.
- 22Explain passed by value and passed by reference?In JavaScript, primitive data types are passed by value and non-primitive data types are passed by reference.
- 23What is MVC?Model–view–controller (usually known as MVC) is a software design pattern commonly used for developing user interfaces that divides the related program logic into three interconnected elements. This is done to separate internal representations of information from the ways information is presented to and accepted from the user.
Model: It directly manages the data, logic and rules of the application.
View: representation of information
Controller: Accepts input and converts it to commands for the model or view. - 24What is promise?Promise is an object representing the eventual completion of failure of an asynchronic operation.
the promise has 3 status : pending, fulfilled and, rejected - 25What is JQuery?jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website.
jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
$("p").hide() - 26What is Traversing?jQuery traversing, which means "move through", are used to "find" (or select) HTML elements based on their relation to other elements. Start with one selection and move through that selection until you reach the elements you desire.
$(".remove").on("click", function(){
alert($(this).closest(".post").data().id)
}) - 27What is module?Modules are a way for us to compartmentalize our code into separate, independent blocks. They keep our code clean and allow for re-usability. They can have closures in them, but don’t have to.
- 28What is Block Scope ?Block scope is related to the variables declared using let and const. Variables declared with var do not have block scope.
Block scope tells us that any variable declared inside a block { }, can be accessed only inside that block and cannot be accessed outside of it. - 29What is specificity in CSS ?Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of different sorts of CSS selectors.
- 30What Is express?Express, is a back end web application framework for Node. js,
Express provides methods to specify what function is called for a particular HTTP verb (GET , POST , SET , etc.) and URL pattern ("Route"), and methods to specify what template ("view") engine is used, where template files are located, and what template to use to render a response - 31What is a block element? Inline?A block-level element always starts on a new line.
A block-level element always takes up the full width available
A block level element has a top and a bottom margin
An inline element does not start on a new line.
An inline element only takes up as much width as necessary.
This is a element inside a paragraph.
Difference whereas an inline element does not. - 32How does specificity work in CSS?Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied.
Specificity is based on the matching rules which are composed of different sorts of CSS selectors. - 33Why don’t we use IDs for all our selectors?Using ID selectors for everything will create a lot of duplicated code and disable reusability. Sometimes we want to group a couple of elements together because they share the same functionality/CSS.
Example: a bunch of buttons on an html page that share the same CSS qualities, using ID selector will be redundant. and will create a lot of duplicate code. - 34What is the box model - why is it useful?In CSS, the term "box model" is used when talking about design and layout.
The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content.
Content - The content of the box, where text and images appear
Padding - Clears an area around the content. The padding is transparent
Border - A border that goes around the padding and content
Margin - Clears an area outside the border. The margin is transparent - 35What are data-attributes good for?allow us to store extra information on standard, semantic HTML elements without other hacks such as non-standard attributes, or extra properties on DOM.
- 36How would you approach fixing browser-specific styling issues?Always build responsive layouts.
Check features of HTML5 and CSS3 on caniuse.com.
Build with cross-browser perspective
Compromise on slightly different looking outcome for each browser. - 37What is OOP?Object-oriented programming (OOP) is a computer programming design pattern that organizes the code around classes, rather than functions and logic. This design patterns highlights 4 important principles which are Encapsulation, Abstraction, Inheritance and Polymorphism.
- 38What is Polymorphism?Polymorphism in OOP is an ability to create a property, a function, or an object that has more than one realization.
Polymorphism it is an ability of multiple object types to implement the same functionality that can work in a different way yet supports a common interface. - 39What is inheritance?Inheritance is an important concept in oop. In the classical inheritance, methods from base class get copied into derived class. In JavaScript, inheritance is supported by using prototype object. Inheritance allows developers to reuse a common logic while still maintaining a unique hierarchy.
Informationen
- Beschreibung
- Computer Science Karteikarten am Interview Questions, erstellt von mediocre msj am 04/07/2021.
- Erstellt von
- mediocre msj
- Aufrufe
- 64
- Tags
- Bewertung