Javascript
In the ever-evolving world of web development, JavaScript stands tall as a cornerstone technology. Its versatility and functionality make it an indispensable tool for creating dynamic and interactive web experiences. we’ll deep dive into the world of JavaScript, exploring its origins, features, and its pivotal role in modern web development.
Understanding JavaScript
JavaScript, often abbreviated as JS, is a high-level, interpreted programming language. It was created by Brendan Eich in just ten days back in 1995. Despite its humble beginnings, it has come a long way and now serves as a fundamental component of web development.
The Role of JavaScript in Web Development
it plays a crucial role in enhancing the user experience on websites. It is primarily responsible for creating interactive elements, handling user input, and facilitating real-time updates without requiring a page reload.
Key Features of JavaScript
it offers a plethora of features that make it an invaluable asset for web developers:
Versatility
it can be used for both front-end and back-end development, making it a versatile choice for building entire web applications.
Easy to Learn
It boasts a relatively simple and intuitive syntax, making it accessible to beginners while remaining powerful for seasoned developers.
Rich Library Ecosystem
JavaScript has a vast library ecosystem, including popular frameworks like React, Angular, and Vue.js, simplifying complex tasks.
Asynchronous Programming
it supports asynchronous programming, allowing developers to perform multiple tasks concurrently, improving overall application performance.
it has come a long way since its inception, evolving into a powerful tool that drives modern web development. Its versatility, ease of use, and rich library ecosystem make it an essential language for creating engaging web experiences. Embracing JavaScript and its best practices empowers developers to build innovative and user-friendly websites.
Introduction to Angular
Angular.js is an open source JavaScript MVC framework developed by Google. Angular.js is an allows to separate presentation logic and application logic on web applications. HTML is generally use for static documents, What happen when we try to use HTML for dynamic views? Is this possible in web-applications? AngularJS is make that possible dynamic HTML […]
How to display image with javascript?
You could make use of the Javascript DOM API. In particular, look at the createElement() method. You could create a re-usable function that will create an image like so… function show_image(src, width, height, alt) { var img = document.createElement(“img”); img.src = src; img.width = width; img.height = height; img.alt = alt; // This next line […]
How to print content of JavaScript object?
Print content of object you can use console.log(obj_str); you can see the result in console like below. Object {description: “test”} For open console press F12 in chrome browser, you will found console tab in debug mode.
Read file in Node.js
Asynchronously reads the entire contents of a file. var fs = require(‘fs’); var path = require(‘path’); exports.testDir = path.dirname(__filename); exports.fixturesDir = path.join(exports.testDir, ‘fixtures’); exports.libDir = path.join(exports.testDir, ‘../lib’); exports.tmpDir = path.join(exports.testDir, ‘tmp’); exports.PORT = +process.env.NODE_COMMON_PORT || 12346; // Read File fs.readFile(exports.tmpDir+’/world.csv’, ‘utf-8’, function(err, content) { if (err) { got_error = true; } else { console.log(‘cat returned […]
Node.js Response.WriteHead function
Up until now all we’ve been sending into the writeHead function is the status code. However, it can take additional parameters like ‘Content-Length’, ‘Content-Type’. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200, {‘Content-Type’: ‘text/html’} ); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080);
Node.js Read File from Server
Now, showing you how to create an HTTP non-blocking server and how to read a file of the non-blocking filesystem. var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHead(200); fs.readFile(‘index.html’, function(err, contents) { response.write(contents); response.end(); }); }).listen(8080); Generate Request curl http://localhost:8080
node.js Convert Blocking
Everyone don’t knows why important to write non-blocking programs in Node.js. Here is some code using non-blocking function “readFile()“ Read the contents of ‘index.html’ and log them to the console. var fs = require(‘fs’); fs.readFile(‘index.html’, function(err, contents){ console.log(contents); });