Topic: JavaScript

Simple React Hello World Example 0

Simple React Hello World Example

Today, We want to share with you Simple React Hello World Example.In this post we will show you react js basics example tutorial, hear for react js examples for beginners we will give you demo and example for implement.In this post, we will learn about react js sample project step by step with an example.

Simple React Hello World Example

There are the Following The simple About Simple React Hello World Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop understanding react js, so the install react and create react app Directory structures for this example is following below.

React js sample project step by step

It simple displays a heading saying “Hello, world!” on the web page.

Syntex

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

Step 1: Run these commands:

npm i
npm start

We only have to simple run npm i the first time using CMD.

Step 2: package.json

{
  "name": "hello-react",
  "version": "1.0.0",
  "description": "pakainfo - Simple React Hello World",
  "main": "index.js",
  "scripts": {
    "start": "browserify -t babelify --outfile public/firstweb-app.js src/hello.jsx && echo 'Open http://localhost:8000/ in your browser' && (cd public ; python -m SimpleHTTPServer)",
    "watch": "watchify -v -t babelify --outfile public/firstweb-app.js src/hello.jsx"
  },
  "author": "",
  "license": "ISC",
  "repository": "none",
  "devDependencies": {
    "babelify": "^6.3.0",
    "browserify": "^11.2.0",
    "watchify": "^3.4.0"
  },
  "dependencies": {
    "react": "^0.14.3",
    "react-dom": "^0.14.3"
  }
}

Step 3: public_index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Simple React Hello World - pakainfo.com</title>
  </head>
  <body>
    <h1>pakainfo.com - Simple React Hello World</h1>
    <div id="root"></div>
    <script src="/firstweb-app.js"></script>
  </body>
</html>

Step 4: src_hello.jsx

import React from "react";
import ReactDOM from "react-dom";

const Hello = function(name) {
  return (
    <div>Hello, {name}</div>
  );
};

const view = Hello("Will");

const element = document.getElementById("root");
ReactDOM.render(view, element);

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple React Hello World Example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Simple Angular Hello World Example 0

Simple Angular Hello World Example

Today, We want to share with you Angular js First Application with demo.In this post we will show you Building “Hello World” in Angular Steps, hear for Introduction and Hello World example we will give you demo and example for implement.In this post, we will learn about Getting Started with Angular: Your First App with an example.

Angularjs Hello World Example

There are the Following The simple About Angularjs Hello World Demo Full Information With Example and source code.

As I will cover this Post with live Working example to develop Angular Or Angular 7 Hello World, so the Angularjs Tutorial – “Hello World” App files and Directory structures for this example is following below.

Hello World with AngularJS module and controller

index.html

<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="utf 8">
    <title>pakainfo.com - AngularJS Your First Example Program </title>     
</head>  
<body ng-app="root">

<h1 ng-controller="HelloWorldCtrl">{{welcomemsg}}</h1>
<p>Angularjs :- The message 'Hello World' will be displayed. </p>

<script src="https://code.angularjs.org/1.6.9/angular.js"></script>
<script>  
    angular.module("root", []).controller("HelloWorldCtrl", function($scope) {  
    $scope.welcomemsg="Hello World" 
    } )
</script> 
</body>  
</html>

AngularJS – My First Hello World Tutorial

Step 01)

HTML Part

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body>

</body>
</html>

step 2 : Angular javascript Part

script.js

var root = angular.module("root", []);
root.controller("HelloController", function($scope) {
  $scope.message = "Hello World, AngularJS";	
});

Step 3: Full Example Code

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<title>AngularJS</title>
<script type="text/javascript" src="assets/js/angular.js"></script>
<script type="text/javascript" src="assets/js/script.js"></script>
</head>
<body ng-app="root">
	<div ng-controller="HelloController">
		<h2>{{message}}</h2>
	</div>
</body>
</html>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about AngularJS first web app Step By Step.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

JavaScript Clone Array Examples 0

JavaScript Clone Array Examples

Today, We want to share with you JavaScript Clone Array Examples.In this post we will show you javascript – how to clone Array without reference, hear for Cloning JavaScript Array in Multiple Ways we will give you demo and example for implement.In this post, we will learn about write a javascript function to clone an array with an example.

JavaScript Clone Array Examples

There are the Following The simple About JavaScript Clone Array Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop Fastest way to duplicate an array in JavaScript, so the How to clone a Javascript Array of Objects? for this example is following below.

Using ES6 Spread operator

var productsObject = [...productsArray];

Using Slice

var productsObject = productsArray.slice();

Using Concat

var productsObject = [].concat(productsArray);

Using Array apply

var productsObject = Array.apply(undefined, productsArray);

Using an Array from

var productsObject = Array.from(productsArray);

Using An Array map

var productsObject = Array.apply(undefined, productsArray);

Using Using loop index

var productsObject = new Array(productsArray.length);
for (var i = 0, l = productsArray.length; i < l; i++) {
  productsObject[i] = productsArray[i];
}

Using Push using loop

var productsObject = [];
for (var i = 0, l = productsArray.length; i < l; i++) {
  productsObject.push(productsArray[i]);
}

Using unshift

var productsObject = [];
for (var i = productsArray.length; i--;) {
  productsObject.unshift(productsArray[i]);
}

Using Serialising then de-serializing

var productsObject = JSON.parse(JSON.stringify(productsArray));

clone an object in JavaScript

const product = {
  string: 'string',
  number: 123,
  bool: false,
  nul: null,
  date: new Date(),  // stringified
  undef: undefined,  // lost
  inf: Infinity,  // forced to 'null'
  re: /.*/,  // lost
}
console.log(product);
console.log(typeof product.date);  // Date object
const clone = JSON.parse(JSON.stringify(product));
console.log(clone);
console.log(typeof clone.date);  // result of .toISOString()

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about JavaScript Clone Array Examples.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

How to get current date and time in VueJS? 0

How to get current date and time in VueJS

Today, We want to share with you How to get current date and time in VueJS?.In this post we will show you Vue.js SimpleDateFormat Example, hear for How to get Current Date and Time in vue with Example we will give you demo and example for implement.In this post, we will learn about how to get current date in vuejs in dd mm yyyy format with an example.

How to get current date and time in VueJS?

There are the Following The simple About How to get current date and time in VueJS? Full Information With Example and source code.

As I will cover this Post with live Working example to develop get vuejs current date in dd-mm-yyyy format, so the some major files and Directory structures for this example is following below.

Vue Js Get Current Date and Time Example

index.html

<!DOCTYPE html>
<html>
<head>
    <title>How to get current date time in vue js? - pakainfo.com</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
   <p>Format date with SimpleDateFormat('MM/dd/yy') in vuejs Example</p>
<div id="root">
    {{ message }}
</div>
  
</body>
  
<script type="text/javascript">
 new Vue({
    el: '#root',
    data: { 
          message:"Welcome To you PAKAINFO.com, Please Wait...."
      },
      methods:{
        callFunction: function () {
   
            var nowDate = new Date();
            console.log(nowDate);
  
            var SimpleDateFormat = new Date().toJSON().slice(0,10).replace(/-/g,'/');
            console.log(SimpleDateFormat);
     
        }
    },
    mounted () {
      this.callFunction()
    }
 });
    
</script>
</html>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to get current date and time in VueJS?.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Angularjs convert json string to array 0

Angularjs convert json string to array

Today, We want to share with you Angularjs convert json string to array.In this post we will show you angularjs convert string to object, hear for we will give you demo and example for implement.In this post, we will learn about convert string to array angular 6 with an example.

Angularjs convert json string to array

There are the Following The simple About simple convert json string to array Full Information With Example and source code.

As I will cover this Post with live Working example to develop angularjs convert string to json array, so the convert object array to string array angularjs for this example is following below.

convert json string to array in AngularJS

index.html

<!doctype html>
<html>
<head>
    <title>AngularJS Convert String to Object Example - pakainfo.com</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
   
<body ng-app='root'>
   
  <div ng-controller="studentController">  </div>
  
</body>
  
<script type="text/javascript">
    
   var app = angular.module('root', []);
  
   app.controller('studentController', ['$scope', '$http', function ($scope, $http) {
   
      $scope.students = "{\"name\":\"Jaydeep\",\"email\":\"[email protected]\" }";
      $scope.myObj = angular.fromJson($scope.students);
   
      console.log($scope.myObj);
   }]);
    
</script>
</html>

Output:
Object
    email: "[email protected]"
    name: "Jaydeep"

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about convert json string to array.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.