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 8081425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:43:37+00:00 2026-06-05T16:43:37+00:00

Object.preventExtensions and Object.seal prevent unknown properties from being added to an object, but those

  • 0

Object.preventExtensions and Object.seal prevent unknown properties from being added to an object, but those attributions silently fail instead of throwing an error. Is there a way to force them to be errors?

var myObj = Object.seal({});
try{
    myObj.someProp = 17;
    console.log("I don't want to reach this message");
}catch(err){
    console.log("I want an error to occur instead.")
    console.log("Or at least get a warning somewhere.");
}

I tested this in Chrome 19 and Firefox 9. I wouldn’t mind browser-specific solutions either, since I would only need this during development.

  • 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-05T16:43:38+00:00Added an answer on June 5, 2026 at 4:43 pm

    If strict mode is an option, Object.seal seems to do the trick (at least in Firefox):

    Attempting to delete or add properties to a sealed object, or to convert a data property to accessor or vice versa, will fail, either silently or by throwing a TypeError (most commonly, although not exclusively, when in strict mode code).

    Works pretty good: http://jsfiddle.net/yVWr6/

    (btw: works the same for preventExtensions())

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

Sidebar

Related Questions

object(stdClass)[1] public 'inbox' => array 0 => object(stdClass)[2] public 'from' => string '55512351' (length=8)
object_getIvar(id object, Ivar ivar) reads the values of iVArs properly but fails on a
Assign object literal properties var foo = { bar : 'hello'}; Ternary var cats
How to merge two JSON objects but do not include properties that don't exist
Object cannot be cast from DBNull to other types. I have a following function
object combinedrows = from dt1 in DsResults.Tables[0].AsEnumerable() join dt2 in DsResults.Tables[1].AsEnumerable() on dt1.Field<string>(MethodName) equals
Object A { def a = { something} } // I've import A, but
Every object has its own public override string ToString(){ return string; } method. But
Object doesn't support this property or method occurs from javascript, and stops at line,
The object I’m working on is instantiated in JavaScript, but used in VBScript. In

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.