Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:47:24+00:00 2026-06-07T22:47:24+00:00

Being curious why the following code gives such a strange results: var f =

  • 0

Being curious why the following code gives such a “strange” results:

var f = function() {}
$.extend(f, Object.freeze({foo1:"bar1"}));

Typing in Chrome (kindly see an update – it’s in Chromium, not Chrome from here and below) console:

> f.foo1

The result in Chrome console is:

> undefined

Furthermore, trying the following:

$.extend(f, {foo2:Object.freeze([1,2,3])});

Typing in Chrome console:

> f.foo2

The result is even stranger:

> function Object() { [native code] }

What am I doing wrong? Why using Object.freeze() has those implications?

Update: Not in Chrome, but in Chromium 18 (the latest on Ubuntu at the moment of writing). I guess this is an implementation bug. Accepting the only answer, though the effect can still be reproduced on my browser.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:47:27+00:00Added an answer on June 7, 2026 at 10:47 pm

    I think this works not like you described:have a look at the jsfiddle here

    It implements your code like this:

    var f = function() {}
    $.extend(f, Object.freeze({
      foo1: "bar1"
    }));
    
    $.extend(f, {
      foo2: Object.freeze([1, 2, 3])
    });
    
    $(document).ready(function() {
      document.getElementById('div').innerHTML = f.foo1.toString() + '<br/>' + f.foo2.toString()
    });​
    

    Object freeze does not prevent attributes and functions being added to your function f. It just freezes the object you actually freeze. jQuery’s extend takes the first argument and extends it with the properties of the second, so the frozen objects in your case will not be touched.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say given a list s = [2,2,2,3,3,3,4,4,4] I saw the following code being used
The following code gives an unreachable statement compiler error public static void main(String[] args)
Reviewing a quite old project I found the following curious code snippet (only relevant
I have the following code 1) var x = {}; x.data = {name: 'name',
Consider the following code: public abstract class Test1 { public object Data { get;
Which of the following code is fastest/best practice for converting some object x? int
Being curious about how maven works exactly, I've checked out its source codes. Astonishingly,
Being somewhat typographically obsessed, I am curious: what is the best way to present
Being new to OpenCL i would like to know if the following scenario is
Let's say I have the following code: // templateClass.h #ifndef TEMPLATE_CLASS_H #define TEMPLATE_CLASS_H template

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.