app not installed as package appears to be invalid.

 


Solution 

Step 1 : Start Android Studio 

Step 2 : Go to Build -> Build Bundles 

Step 3 : Select Build APK

Step 4 : Build APK file



How to Rename an Object's Key in JavaScript | Demo | Example

Demo URl

Code Example Here

 function renameKeys(obj, newKeys) {

  const keyValues = Object.keys(obj).map(key => {
    const newKey = newKeys[key] || key;
    return { [newKey]: obj[key] };
  });
  return Object.assign({}, ...keyValues);
}

Uses

 const obj = { a: "1", b: "2" };
const newKeys = { a: "A", c: "C" };
const renamedObj = renameKeys(obj, newKeys);
console.log(renamedObj);
// {A:"1", b:"2"} 



How many ways to create Objects in JavaScript

 We can 5 ways to create objects in JavaScript.

Lets understand how to Create it...

Demo URL



'use strict';
Example 1

var fruit = {};
fruit.name = 'Mango';
fruit.color = 'Yellow';
console.log(`fruit name ${fruit.name} and color is ${fruit.color}`);

Example 2

var fruit2 = { name: 'Mango'color: 'Yellow' };
console.log(`fruit name ${fruit2.name} and color is ${fruit2.color}`);

function Fruit(namecolor) {
  (this.name = name), (this.color = color);
}

Example 3

var fruit3 = new Fruit('Mango''Yellow');

Example 4

var fruit4 = new Fruit('Donut''Sprinkled Yellow');

console.log(`fruit name ${fruit3.name} and color is ${fruit3.color}`);
console.log(`fruit name ${fruit4.name} and color is ${fruit4.color}`);

console.log(`Check fruit3 proto ${Fruit.prototype === fruit3.__proto__}`);

// console.log(`Property descriptor
// ${JSON.stringify(Object.getOwnPropertyDescriptor(fruit,'name'))}`)

Example 5

var fruit5 = Object.create(Object.prototype, {
  name: {
    value: 'Mango',
    enumerable: true,
    writable: true,
    configurable: true,
  },

  color: {
    value: 'Yellow',
    enumerable: true,
    writable: true,
    configurable: true,
  },
});

console.log(`fruit name ${fruit5.name} and color is ${fruit5.color}`);
console.log(`Check fruit3 proto ${fruit.prototype === fruit5.__proto__}`);

var fruit6 = Object.create(Object.prototype, {
  name: {
    value: 'Mango',
    enumerable: true,
    writable: true,
    configurable: true,
  },

  color: {
    value: 'Yellow',
    enumerable: true,
    writable: false,
    configurable: true,
  },
});

fruit6.name = 'Sausages';
//compile error comment it later
//fruit6.color="Red";

for (var props in fruit6) {
  console.log(`${props} : ${fruit6.color}`);
}

console.log(
  `Fruit name ${fruit6.name} and color is ${
    fruit6.color
  } and proto ${JSON.stringify(fruit6.__proto__)}`
);

//Getter Setter

var fruit7 = {
  color: 'Yellow',
  get fruitcolor() {
    return this.color;
  },
  set fruitcolor(val) {
    this.color = val;
  },
};

console.log(`Fruit default color is ${fruit7.fruitcolor}`);

fruit7.fruitcolor = 'Yellow';

console.log(`Fruit changed color is ${fruit7.fruitcolor}`);

console.log(`Check Fruit3 proto ${Fruit.prototype === fruit3.__proto__}`);


What is the difference between Components and Directives?

 
Demo URL



@Components

@Directives

For register component we use @Component

meta-data annotation.


For register directives we use @Directive meta-data annotation.


Component is a directive which use shadow

DOM to create encapsulate visual behavior

called components. Components are typically

used to create Ul widgets.


Directives are used to add behavior to an existing DOM element.

Component is used to break up the application into smaller components.


Directive is used to design reusable components.



Only one component can be present per DOM element.


Many directive can be used in a per DOM element



Component is used to define pipes

You can't define Pipes in a directive.



@View decorator or templateurl template are

mandatory in the component.


Directives don't have a View.


What is the difference between constructor and ngOnInit? | Demo | Example



Demo URL




Constructor

ngOninit 

A constructor is not the concept of Angular. It is the concept of JavaScript's class.


ngOninit is the second stage of Angular

component lifecycle hook whenever is called

when angular is done which creating the

component.


Constructor is best place to add all dependencies


ngOninit function which guarantees you that the component has already been created.


Constructor is automatically called at the time of creating the object of the class.


Invoked by Angular when component is initialized


Used for Injecting dependencies


Actual business logic performed 



we should use constructor() to setup Dependency Injection

is a better place to write "actual work code" that we need to execute as soon as the class is instantiated.

CPU vs GPU Architecture

  CPU vs GPU Architecture CPU (Central Processing Unit) and GPU (Graphics Processing Unit) have distinct architectural differences, optimize...

Best for you