No need for $.each in the modern world, arrays have forEach and such (which you can shim if you really need to support obsolete browsers like IE8).
If pk can have 100 entries and you're filtering 4,000 records, I'd build a map of pk values and use that. Here's an ES5 approach:
var b = [
{"pk":"1","name":"Ali","marked":"N" },
{"pk":"2","name":"Zeeshan","marked":"N" },
{"pk":"3","name":"Tariq","marked":"N" }
];
var pk = ["2", "3"];
// Build the "map"
var map = Object.create(null);
pk.forEach(function(value) {
map[value] = true;
});
// Mark relevant entries
b.forEach(function(entry) {
if (map[entry.pk]) {
entry.marked = "Y";
}
});
console.log(b);
This avoids constantly calling pk.indexOf(entry.pk) to see if an entry should be marked, which requires re-scanning the array each time. Instead, it leverages the JavaScript engine's object property lookup code, which is highly optimized on modern browsers (even unoptimized it would likely be some kind of hash map or similar, but they optimize these days).
If you did want to use $.each instead, just change
pk.forEach(function(value) {
to
$.each(pk, function(_, value) {
// Note ------------^
and the same for the b loop later. $.each calls the callback with the index of the entry as the first argument, and then the value.