Posts

Es6 Module

Image
Export-Import in ES6 JavaScript's ES6 allow you to organize the code components in the form of modules and can be import them into other modules. This makes code maintenance easier. If they are written in separate files. With the help of import and export keywords, Modules can be used in other programs. Using Export You can export a function or variable from any file. Let us create a file named employee.js, and fill it with the things we want to export. There are two types of exports: 1. Named and 2. Default. Named exports must be enclosed using curly braces. Default exports do not. Named Exports You can create named exports two ways. 1. In-line individually, or 2. All at once at the bottom. MOVETOP↑   Example In-line individually: export const empname = "benny" export const empage = 30 // first declare variable and export let empcompany = "xyz" export {empcompany } All at once at the bottom: employeerecord.js // first declare variable and export cons...

PHP Mini Project for Beginners

Image
   PHP Mini Project for Beginners Here is a small PHP Project, which will displays a list of items from the selected category.   This project gives you how to use a multidimensional array, function, and switch statement in Real-time scenario.    Description :   There is only one PHP file called main.php. Which implements above concepts in this project. 1. Nested array : array is a multidimensional array contains different category of products 2. Function : There is a function called display(). This function takes products array as an argument and display all the products from the given array. 3. Switch statement : Identifies the category and calls display() function and passes the products array(nested array key element, which points to another array of products. And some CSS Code.    main.php      <html> <head> <title> PHP Mini Project </title> <style type= "text/css" > body { align: cen...

Es6 Destructuring

Image
Es6 Destructuring  ES6HOME What is Destructuring Destructuring makes it easy to extract array values from any index. Using Destructuring With destructing, we can assign array items to variables:   const userdata = [ 'John' , 'john@gmail.com' , '123451234' ]; const [name,email, phone] = userdata ; // assiging array values to different variables.     When destructuring arrays, Keep in mind the order of the variables that you are providing. To extract only name,phone write the following way. const [name,,phone] = userdata ;       MOVETOP↑   Destructuring with Array Default values The following example shows how Array Destructuring Assignment will work with array Default value. const userdata = [ 'John' , 'john@gmail.com' , '123451234' ]; onst [name = "John" , email = "john@gmail.com" ] = [ "Doe" ]; console.log(name); // Deo console.log(email); // john@gmail.com     Using array destructurning...