Beta
What Happened To My Object?
Loading description...
Puzzles
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
You still have 2 big exploits to fix:
https://www.codewars.com/kata/reviews/5b59a8753237d248d6003489/groups/5b59b7273237d2a42d0037d7 https://www.codewars.com/kata/reviews/5b59a8753237d248d6003489/groups/5b7c5add5d191a2b9f00009e
You're also not checking if user functions would make visible changes on the object after going through the function.
I'd say it's a really, really, really bad practice for this kata to have solutions that mutates the input mercilessly ;-)
You are also mixing up the property of the properties of the object, and the object itself.
A perfectly normal object can have all its properties frozen (
writable: false
). It's just a side effect that whenever you freeze/seal an object, it also applies to all the properties. WhenObject.isFrozen
and the like is called, it checks about the object itself, and not its properties, and yet by how your tests are written, doing the latter will pass your weak tests just fine.Since
freeze
>seal
>preventExtensions
strictly, your requirements are suggesting a different behaviour from the original functions inObject
. Naming them the same is really asking for confusion.You should really name it something like
isOnlyFrozen
or something.There is no way to determine properties can be updated in an object if it has no properties to begin with (i.e
{}
).If all objects are supposed to be non-empty it should be mentioned in the descriptions.
but
Hmmm...interesting, interesting.
From my understanding, in that particular case, Object.freeze() was invoked with frozenObj being passed in as the argument. This means that invoking isFrozen(frozenObj) would result in a return value of the boolean true. It is up to here where we are on the same page, it seems.
Now, we're at the point where we have to determine if a frozen object should, in fact, be sealed. At the moment, the tests are written in a way where a frozen object cannot and should not also be considered sealed.
Part of the reason for this is because, taking that same frozen object scenario, we cannot do this:
However, if the object was sealed instead, something different happens:
In both cases, when an object is frozen or when an object is sealed:
Where they differ, as seen in the code blocks above, is the fact that a property on a frozen object cannot be updated/overwritten whereas a property on a sealed object can be updated/overwritten.
For this distinct reason, it seemed to make more sense (to me) to consider a frozen object as solely frozen. In other words, the fact that we could essentially edit a sealed object but we are unable to edit a frozen object was enough grounds for me to separate the two conditions (frozen/sealed) instead of allowing the object to exist in multiple states/conditions.
If this is bad practice, or if I'm completely off-the-mark and I am misunderstanding, please let me know! I want to make sure this is as on-point as possible.
Thank you!
You are... complicating the task... From https://msdn.microsoft.com/library/ff806188(v=vs.94).aspx (if msdn redirected to mdn, please clear your browser cache or enter secret mode, change the language to any other than English and try load again).
(Seems that discuss section md does not support tables...)
Talking about 'best' practice, when we trying to exam the function of a builtin function, we should ONLY rely on the specfication. From ECMA-262 8th Edition / June 2017.