Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js.private

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js.private

Private properties for objects

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm install js.private --save

Usage

  
import Private from "js.private";

class People {

  constructor( firstname, lastname, gender, city, street ){
    $( this ).firstname       = firstname;  // private property
    $( this ).lastname        = lastname;   // private property
    $( this ).address.country = country;    // private property
    $( this ).address.city    = city;       // private property
    this.gender               = gender;     // public  property
  }

  get name(){
    return $( this ).generateName();        // call private method
  }

  get info(){
    return this.gender + ", " + $( this ).age;
  }
  
  get address(){
    return $( this ).address.city + ", " + $( this ).address.street;
  }

}

const $ = Private({
  firstname: "", // Default values
  lastname:  "", 
  age:       28, 
  address: {
    country: "",
    city:    ""
  },
  generateName: function(){
    return $( this ).firstname + " " + $( this ).lastname;
  }
});


let ivan = new People( "Ivan", "Ivanow", "man", "Russia", "Moscow" );

ivan.name          // > "Ivan Ivanov"
ivan.info          // > "man, 28"
ivan.address       // > "Russia, Moscow"

let anna = new People( "Anna", "Ananina", "woman", "Germany", "Berlin" );

ivan.name          // > "Anna Ananina"
ivan.info          // > "woman, 28"
ivan.address       // > "Germany Berlin"

ivan.lastName      // > undefined
anna.gender        // > "woman"
ivan.generateName  // > undefined

FAQs

Package last updated on 22 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc