Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
JavaScript is a programming language of HTML and WEB. It is lightweight and most commonly used as part of web pages, but their implementation allows Client-Side scripts to interact with users and create dynamic websites. It is an interpreted programming language with object-oriented capabilities.

Introducing JavaScript

JavaScript was first known as Mocha, and then LiveScript, but Netscape changed its name to JavaScript, because of its popularity as a Java phenomenon at the time. JavaScript first appeared in Netscape 2.0 in 1995 with the name LiveScript. The versatile core of this language has been embedded in Netscape, IE, and other browsers.
The ECMA-262 Specification defines a standard version of the JavaScript language as follows:
  • JavaScript is a lightweight, interpreted program language.
  • Designed to create central network applications.
  • Add and integrate with Java.
  • Add and integrate with HTML.
  • Open and multi-platform.

Client-side JavaScript

Client-Side JavaScript is the most popular form of this language. The script should be included in an HTML document for coding to be interpreted by the browser.
This means that a website doesn't need to be a static HTML, but can include programs that interact with users, control the browser, and create dynamic HTML content.
Client-Side JavaScript technology provides many advantages over the CGI Server-Side Script. For example, you can use JavaScript to check if the user has entered a valid email address in a Form field.
JavaScript code is executed when the user submits a Form, and only if all inputs are valid, they will be submitted to the Web Server.
JavaScript can be used to capture user-initiated events such as clicks, link navigation, and other activities that users create.

The advantages of JavaScript

The advantages of using JavaScript are:
  • Less Server interaction: You can confirm user input before sending the page to the Server. This saves server load, meaning that your server loads less.
  • Immediate feedback to visitors: They don't have to wait for a site to reload to see if they forgot to enter something.
  • Increased interoperability: You can create interfaces that react when users hover over them or activate them via the keyboard.
  • Richer interface: You can use JavaScript to include items such as Drag and Drop components (DnD) and sliders (Slider) to provide a Rich Interface to the guest site. your access.

Limitations of JavaScript

We cannot treat JavaScript as a full-fledged program language. It lacks the following important features:
  • Client-side JavaScript does not allow reading and writing files, because of security reasons.
  • JavaScript is not used for networking applications because there are no support available.
  • JavaScript does not have any multi-threading or multi-processing capabilities.
Again, JavaScript is a lightweight, interpreted program language that allows you to build interoperability in static HTML pages.

You may be asking why, the answer is actually quite simple. In programming we are not always in control of the format in which our data is delivered to us. With this in mind it becomes important to understand how to convert our data into our desired format. Check out, How to convert an object to an array of objects in Javascript?
//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js





Example


Using newer Javascript features there is an easy one liner that can achieve this result using Object.values().


const profileObj = 
first: 'Panayiotis',
last: 'Georgiou',
links:
twitter: 'https://twitter.com/panay_georgiou',
facebook: 'https://facebook.com/panayiotisgeorgiou.net',
cv: 'https://www.panayiotisgeorgiou.com',
blog: 'http://www.panayiotisgeorgiou.net',

;

const profileArray = Object.values(profileObj);

You can use this if you are using babel but if not I will show you below how you can do this in a more widely supported manner with Object.keys().


const profileArray = Object.keys(profileObj).map(i =>profileObj[i])




This second method is quite well supported. Check out both Object Values and Object Keys MDN documentation to learn where you may have issues with support and for more info on these features.


As a note, if you prefer a key valued pair check out Object Entries.


That’s it for now.


If you liked this article, then please subscribe to my YouTube Channel for video tutorials.


You can also find me on Twitter and Facebook.



Don’t miss out ..


Destructuring JavaScript Objects


Arrow Functions for Beginners Javascript








The post How to convert an object to an array of objects in Javascript? appeared first on Panayiotis Georgiou.