
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
get-or-else
Advanced tools
Simple Get Or Else module written in JavaScript ES5.
Request an object property at a given namespace with a backup value, incase the desired namespace does not yield a result.
Useful if you have an untrustworthy or deeply nested data source. It will probably save you a bit of if, else-ery.
var get = require("get-or-else");
window.a = { x: 4 };
get([ window, 'a.b.c' ], {});
// returns {} as window.a.b.c does not exist, so `else` is used
get([ window, 'a' ], {});
// returns { x: 4 } as window.a does exist, so expected value is returned
import get from 'get-or-else';
export const name = (state = {}, action = {}) => {
switch(action.type) {
case 'SET_FIRSTNAME':
return {
...state,
firstName: get([ action, 'payload.name.first' ], undefined)
};
default:
return state;
}
};
see this repo get-or-else-demo
import React from 'react';
import ReactDOM from 'react-dom';
import get from 'get-or-else';
const nameObj = {
details: {
salutation: undefined,
name: {
first: 'Margaret'
}
}
};
const NameComponent = () => (
<h1>
Welcome {get([ nameObj, 'details.salutation' ], 'back')}
<span> {get([ nameObj, 'details.name.first' ], '')}</span>
<span> {get([ nameObj, 'details.name.last' ], '')}</span>
</h1>
);
ReactDOM.render(
<NameComponent />,
document.getElementById('root')
);
/* NameComponent Renders `
<h1>
Welcome back<span> Margaret</span><span></span>
</h1>`
nameObj.details.salutation does not exist so the backup value is used
nameObj.details.name.last does not exist so it does not display
*/
IE 9 or greater - Array.every on Mozilla's compatibility chart
Given you have Node installed, cd into this folder and:
npm install
npm test
FAQs
Get Or Else in Javascript
We found that get-or-else demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.