1. What is DOCTYPE in HTML?
DOCTYPE is an instruction that is used in the beginning of an HTML or XHTML document to inform a web browser about the version and type of HTML or XHTML being used. It is not an HTML tag; it is an "information" to the browser about what document type to expect. It is important to include the DOCTYPE in your HTML documents in order for the browser to correctly render the content of your web page.
2.What are the new HTML5 features?
Semantic Elements: HTML5 introduces new semantic elements like <header>, <nav>, <article>, <section>, <aside>, <figure> and <figcaption>, which provide additional meaning to the content of a web page.
Audio and Video Support: HTML5 includes built-in support for audio and video, eliminating the need for third-party plugins like Flash.
Canvas: HTML5 introduces the <canvas> element, which allows for dynamic, scriptable rendering of 2D shapes and bitmap images.
Web Storage: HTML5 provides a way for web pages to store data locally on the user's device, making it possible to create web apps that work offline.
Web Sockets: HTML5 enables real-time communication between the browser and a server, allowing for faster and more efficient web applications.
Web Workers: HTML5 allows for the execution of JavaScript in the background, independent of the user interface, thus allowing for more complex and responsive web applications.
Form Validation: HTML5 includes new form controls and validation features that make it easier to create and validate forms without the need for JavaScript.
Microdata: HTML5 allows for the embedding of structured data within HTML documents, making it easier for search engines to understand the content of a web page.
3. What is Flexbox, Difference between flex and grid?
Flexbox is a layout module in CSS3 that allows for the creation of flexible and responsive designs. It provides a way to align and distribute elements within a container, and it's particularly useful for creating one-dimensional layouts, such as rows or columns.
Grid Layout is a two-dimensional layout system for the web, that allows for the creation of grid-based layouts using rows and columns. It's particularly useful for creating complex, multi-dimensional layouts, such as grids of items.
The main difference between Flexbox and Grid is the dimension they are used for. Flexbox is used for one-dimensional layouts, while Grid is used for two-dimensional layouts. Flexbox is also more simple to use and understand, while Grid is more powerful and flexible, but also more complex. Flexbox is good for creating flexible and responsive designs with a single-axis of layout, while Grid is great for creating more complex multi-dimensional designs with rows and columns.
4.Difference between map and foreach?
Both map() and forEach() are array methods in JavaScript, but they have different use cases.
map() is used to create a new array with the results of calling a provided function on every element in the calling array. It returns a new array containing the results of the function call on each element, and the original array remains unchanged.
forEach() is used to execute a provided function once for each array element. It does not return a new array, and it does not change the original array. The function passed to forEach is called for every element of array and returns nothing.
5. What is the slice and splice method in javascript?
slice() is a JavaScript array method that returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will remain unchanged.
splice() is a JavaScript array method that changes the contents of an array by adding or removing elements. It modifies the original array and returns the removed elements (if any) as a new array.
6.What is Hoisting, and how to avoid hoisting?
Hoisting is a behavior in JavaScript where variable and function declarations are moved to the top of their scope, regardless of where they are actually declared in the code. This means that variables and functions can be used before they are declared, which can lead to confusion and unexpected behavior.
Comments
Post a Comment