Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

binary function

String.prototype.bin = function () {
        return parseInt(this, 2);
    };
    Number.prototype.bin = function () {
        var sign = (this < 0 ? "-" : "");
        var result = Math.abs(this).toString(2);
        while(result.length < 32) {
            result = "0" + result;
        }
        return sign + result;
    }

//result
console.log("110".bin())
//00000000000000000000000000000110
console.log(6..bin())
//6
Comment

PREVIOUS NEXT
Code Example
Javascript :: accessing state in nuxt vuex 
Javascript :: expression expected.ts switch case 
Javascript :: public url react for serving django static in production 
Javascript :: jsx expressions 
Javascript :: javascript random letters and numbers 
Javascript :: split name js 
Javascript :: convert todays date to json datetime 
Javascript :: node js 42school 
Javascript :: get first and last word initials from name 
Javascript :: remove package-lock.json from commit 
Javascript :: Get JSON Key In Array Alternative Syntax 
Javascript :: es6 spread operator 
Javascript :: This is the JSON 
Javascript :: compare strings to multiple strings javascript 
Javascript :: nodejs express parse query params boolean 
Javascript :: freecodecamp using props to render conditionally 
Javascript :: javascript one linde condition 
Javascript :: new date is not working in react js 
Javascript :: Mirror Inverse Program in javascript 
Javascript :: react native picker select placeholder color 
Javascript :: erc721 abi json 
Javascript :: context 
Javascript :: hide header on button click in react native 
Javascript :: react js date range 
Javascript :: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile 
Javascript :: hreroku 
Javascript :: how to get specific property name with numbers from object in javascript 
Javascript :: setCount 
Javascript :: Timeout error when trying to use npx create-react-app 
Javascript :: js draw number in range 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =