Skip to content
Snippets Groups Projects
Commit 26157969 authored by Josh Wolfe's avatar Josh Wolfe Committed by Rick Waldron
Browse files

NumberFormat formatToParts with no arguments

parent 968a2e04
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: #sec-intl.numberformat.prototype.formattoparts
description: Intl.NumberFormat.prototype.formatToParts called with no parameters
info: >
Intl.NumberFormat.prototype.formatToParts ([ value ])
3. If value is not provided, let value be undefined.
---*/
var nf = new Intl.NumberFormat();
// Example value: [{"type":"nan","value":"NaN"}]
var implicit = nf.formatToParts();
var explicit = nf.formatToParts(undefined);
assert(partsEquals(implicit, explicit),
"formatToParts() should be equivalent to formatToParts(undefined)");
function partsEquals(parts1, parts2) {
if (parts1.length !== parts2.length) return false;
for (var i = 0; i < parts1.length; i++) {
var part1 = parts1[i];
var part2 = parts2[i];
if (part1.type !== part2.type) return false;
if (part1.value !== part2.value) return false;
}
return true;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment