An open API service indexing awesome lists of open source software.

https://github.com/jokeyrhyme/is-es5-supported

does this JavaScript environment conform to ECMAScript 5?
https://github.com/jokeyrhyme/is-es5-supported

ecmascript ecmascript5 feature-detection javascript

Last synced: 3 months ago
JSON representation

does this JavaScript environment conform to ECMAScript 5?

Awesome Lists containing this project

README

        

# is-es5-supported.js [![npm module](https://img.shields.io/npm/v/is-es5-supported.svg)](https://www.npmjs.com/package/is-es5-supported) [![Travis CI Status](https://travis-ci.org/jokeyrhyme/is-es5-supported.svg?branch=master)](https://travis-ci.org/jokeyrhyme/is-es5-supported)

does this JavaScript environment conform to ECMAScript 5?

## What is this?

I made this after reading [Kangax](https://github.com/kangax)'s terrific
[ES5 compatibility table](http://kangax.github.io/compat-table/es5/). Rather
than feature-detect every single piece of ECMAScript 5, I've selected the
smallest number of tests to identify non-conformant JavaScript environments.

> `parseInt()` ignores leading zeros

- after this test, we get a `false` in most old browsers

> Strict Mode

- after this test, we get a `false` in Internet Explorer 9 and environments or
apps that load [ES5-shim](https://github.com/es-shims/es5-shim)

> `Date.prototype.toISOString`

- after this test, we get a `false` in EJS

Job done!

## Supported Environments

I've manually tested in a range of environments:

- `true`: Node.js (0.12), Chrome (43), Safari (8), Firefox (38), Internet
Explorer (10, 11), Edge

- `false`: Internet Explorer (6, 7, 8, 9)

## Usage

- CommonJS (e.g. Node.js, Browserify, etc) use [index.js](index.js)

```javascript
var isES5Supported = require('is-es5-supported');
console.log(isES5Supported); // `true` or `false`
```

- [dist/index.js](dist/index.js) is a UMD-wrapped version for browsers and AMD

```html

console.log(isES5Supported); // `true` or `false`

```

## Known Issues

- this approach does assume correlations between the 3 included tests and the
rest of the ECMASCript 5 implementation, which might not return correct
results in exotic environments

- Internet Explorer 10 Platform Preview 2 will get a `false` (who cares?)