JavaScript
JavaScript is one of the most popular programming languages in the world, and is now widely used also outside of the browser. The rise of Node.js in the last few years unlocked back-end development — once the domain of Java, Ruby, Python, PHP, and more traditional server-side languages.
A basic definition of JavaScript
JavaScript is a programming language that is:
- High level: It provides abstractions that allow you to ignore the details of the machine where it’s running. It manages memory automatically with a garbage collector, so you can focus on the code instead of managing memory locations, and provides many constructs which allow you to deal with highly powerful variables and objects.
- Dynamic: As opposed to static programming languages, a dynamic language executes at runtime many of the things that a static language does at compile time. This has pros and cons, and it gives us powerful features like dynamic typing, late binding, reflection, functional programming, object runtime alteration, closures and much more.
- Dynamically typed: A variable does not enforce a type. You can reassign any type to a variable, for example assigning an integer to a variable that holds a string.
- Weakly typed: As opposed to strong typing, weakly (or loosely) typed languages do not enforce the type of an object. This allows more flexibility but denies us type safety and type checking (something that TypeScript and Flow aim to improve)
- Interpreted: It’s commonly known as an interpreted language, which means that it does not need a compilation stage before a program can run, as opposed to C, Java or Go for example. In practice, browsers do compile JavaScript before executing it, for performance reasons, but this is transparent to you as there is no additional step involved.
- Multi-paradigm: The language does not enforce any particular programming paradigm, unlike Java for example which forces the use of object-oriented programming, or C that forces imperative programming.
What is the role of a browser?
A browser is a software application that gives access to information on the World Wide Web. When a user asks for a particular website, the web browser fetches the required content from a web server. And then, it displays the resulting web page on the user’s device.
Other than accessing the website, browser also acts as an interpreter for JavaScript, HTML and CSS and recognizes all the events taking place in window like mouse clicks, mouse position & movements, keyboard clicks, etc.
What is an event in browser?
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired. For example, if the user selects a button on a webpage, you might want to respond to that action by displaying an information box.
An event is a signal that something has happened. All DOM nodes generate such signals (but events are not limited to DOM).
Here’s a list of the most useful DOM events, just to take a look at:
Mouse events:
click
– when the mouse clicks on an element (touchscreen devices generate it on a tap).mouseover
/mouseout
– when the mouse cursor comes over / leaves an element.mousedown
/mouseup
– when the mouse button is pressed / released over an element.mousemove
– when the mouse is moved.
Keyboard events:
keydown
andkeyup
– when a keyboard key is pressed and released.
Document events:
DOMContentLoaded
– when the HTML is loaded and processed, DOM is fully built.
CSS events:
transitionend
– when a CSS-animation finishes.
Write the syntax of print statement in JavaScript?
In HTML, JavaScript code is inserted between <script>
and </script>
tags.
JavaScript can “display” data in different ways:
- Writing into an HTML element, using
innerHTML
. - Writing into the HTML output using
document.write()
. - Writing into an alert box, using
window.alert()
. - Writing into the browser console, using
console.log()
.
What is the meaning of DOM in web technology?
The Document Object Model (DOM) is a programming interface for HTML and XML(Extensible markup language) documents. It defines the logical structure of documents and the way a document is accessed and manipulated.
Note: It is called a Logical structure because DOM doesn’t specify any relationship between objects.
Which are the box that JavaScript support?
JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.
Alert Box
An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click “OK” to proceed.
Confirm Box
A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either “OK” or “Cancel” to proceed. If the user clicks “OK”, the box returns true. If the user clicks “Cancel”, the box returns false.
Prompt Box
A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either “OK” or “Cancel” to proceed after entering an input value. If the user clicks “OK” the box returns the input value. If the user clicks “Cancel” the box returns null.
What is the need of AJAX?
AJAX stands for Asynchronous JavaScript and XML. It is used for allowing the client side of an application to communicate with the server side of the application. Before AJAX, there was no way for the client side of a web application to communicate directly with the server. Instead, you would have to use page loads. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
How to use JSON in JavaScript?
JSON stands for JavaScript Object Notation. JSON’s format is derived from JavaScript object syntax, but it is entirely text-based. It is a key-value data format that is typically rendered in curly braces.
When you’re working with JSON, you’ll likely see JSON objects in a .json
file, but they can also exist as a JSON object or string within the context of a program.
Front end development
Front end development is mostly focused on what some may coin the “client side” of development. Front end developers will be engaged in analyzing code, design, and debugging applications along with ensuring a seamless user experience. You manage what people first see in their browser. As a front end developer you are responsible for the look, feel and ultimately design of the site.
Front end languages include HTML, CSS, and Javascript. While JQuery is going out of style (modern browsers can now do the same work, but much more quickly than jQuery), many legacy projects still use JavaScript library, so don’t be surprised to see it on a bootcamp’s curriculum. You’ll also learn tons about responsive design along with typography, layouts, grid system, and color theory. When anticipating types of projects you’ll work on as a front end developer, think creating and redesigning websites. In order to be a front end developer (sometimes even called a Javascript developer) you do not need back end development skills. Sites created by front end developers won’t interact with information stored on a database in order to be functional. The content will be “fixed,” meaning that large pieces of new data will not be constantly uploaded. Small business owners and restaurants usually have great examples of static sites.
Back end Development
Back end Development refers to the server side of development where you are primarily focused on how the site works. Making updates and changes in addition to monitoring functionality of the site will be your primary responsibility. This type of web development usually consists of three parts: a server, an application, and a database. Code written by back end developers is what communicates the database information to the browser. Anything you can’t see easily with the eye such as databases and servers is the work of a back end developer. Back end developer positions are often called programmers or web developers.
Many back end developers know front end languages such as HTML and CSS but need to use languages such as Java, PHP, Ruby on Rails, Python, and .Net to get the back end job done. Back end developers are most focused on a site’s responsiveness and speed. These languages are used to create dynamic sites which are different from static sites in that these types of websites store database information. Content on the site is constantly changing and updating. Examples of dynamic sites include Facebook, Twitter, and Google Maps.