Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Currently...
- (function () {
- var forEach = (function () {
- var forEach;
- function Properties() {
- this.toString = 1;
- }
- Properties.prototype.toString = 1;
- // Iterate over a new instance of `Properties` to detect `for...in` bugs.
- if (!size) {
- // JScript fork.
- forEach = function forEach() {
- // ...
- };
- } else if (size == 2) {
- // Safari 2 fork.
- forEach = function forEach() {
- // ...
- }
- } else {
- // Normal environments.
- forEach = function forEach() {
- // ...
- };
- }
- return forEach;
- }());
- }());
- // Possible Future Implementation...
- (function () {
- // Define the library methods without forking.
- var hasOwnProperty = {}.hasOwnProperty;
- function forEach(iterator, object) {
- // ...
- }
- function fold(iterator, memo, object) {
- // ...
- }
- function isPropertyOf(object, property) {
- // ...
- }
- // Implement `hasOwnProperty` in Safari 2.
- if (typeof hasOwnProperty != 'function') {
- hasOwnProperty = function (property) {
- // ...
- };
- }
- // Use defined library methods to detect `for...in` bugs in legacy engines.
- function Properties() {
- this.toString = 1;
- }
- Properties.prototype.toString = 1;
- if (fold(function (memo) {
- return ++memo;
- }, 0, new Properties) != 1) {
- // Wrap the `forEach` function in IE and Safari 2.
- }
- }());
Add Comment
Please, Sign In to add comment